The officer before whom such party is brought on such writ shall immediately after the return thereof, proceed to examine into the facts contained in such return, and into the cause of the confinement or restraint of such party, whether the same was before commitment for any criminal charge or not.
NMS § 44-1-14