No person shall be discharged upon the hearing of a writ of habeas corpus in the following cases: (1) When he is imprisoned under lawful process issued from a court of competent jurisdiction unless his case is one in which bail is allowed and proper bail is tendered; (2) By reason of any irregularity in the warrant or commitment where the same substantially conforms to the requirements of law; (3) For want of bond to prosecute; (4) When the person is imprisoned under a bench warrant which is regular upon its face; (5) By reason of any misnomer in the warrant or commitment when the court is satisfied that the person detained is the party charged with the offense; (6) When the person is in custody for a contempt of court and the court has not exceeded its jurisdiction in the length of the imprisonment imposed; or (7) In any other case in which it appears that the detention is authorized by law. (Orig. Code 1863, § 3924; Code 1868, § 3947; Code 1873, § 4023; Code 1882, § 4023; Penal Code 1895, § 1224; Penal Code 1910, § 1305; Code 1933, § 50-116.)