The applicant for a writ of habeas corpus may deny any of the material facts set forth in the return or may allege any fact to show, either that the imprisonment or detention is unlawful or that he is then entitled to his discharge, which allegations or denials shall be made on oath. The return may be amended by leave of the court or judge, before or after the same is filed, as also may all suggestions made against it, in order that all material facts may be ascertained.
SDCL 21-27-13