When the parties do not consent, the court may, upon application of either, or of its own motion, direct a reference (1) where the trial of an issue of fact shall require the examination of mutual accounts, or where the account is on one side only, and it shall be made to appear to the court that it is necessary that the party on the other side should be examined as a witness to prove the account; in which cases the referees may be directed to hear and report upon the whole issue, or upon any specific question of fact involved therein;
(2) where the taking of an account shall be necessary for the information of the court before a judgment, in cases which may be determined by the court or for carrying a judgment into effect; or
(3) where a question of fact, other than upon the pleadings, shall arise upon motion or otherwise, in any state of an action.