When the accused is not entitled to bail, or where he fails to give bail, and there is no county jail or the jail of the county in which the offense is committed, or where the case stands for trial is, in the opinion of the committing officer or of the court having jurisdiction of the case or of the presiding judge, insufficient for the accommodation of the prisoners, or where the judge having jurisdiction of the case shall think it expedient, on grounds of public policy, so to do, it shall be the duty of the officer of the court, or circuit judge, to make an order for the removal of the accused to a convenient and safe jail of some convenient county, there to be kept until the court shall sit for the trial of the accused. It shall be the duty of the sheriff of the county to which the prisoner is so removed, to receive and safely keep him, according to the order of the court or officer having jurisdiction thereof; and it shall further be the duty of said sheriff to have the body of the accused, without further order, before the proper court of the proper county, at its next term thereafter, on the first day of the term, unless he shall have been discharged by due course of law. The county in which the offense is committed, or where the case stands for trial, shall pay all the expenses of such removal and safekeeping and return of the accused for trial.