Section 22. The court may issue a writ of habeas corpus to bring before it for examination or disposition or for the purpose of giving bond, a defendant or debtor, or, in the case of a corporation or trust with transferable shares, its officer, trustee or agent who has been imprisoned under the provisions of this chapter.