§ 27. When claimants entitled to ratable distribution. If the aggregate amount of the liabilities, which might be recovered by actions upon an official bond or undertaking, as prescribed in this article, exceeds the sum for which the sureties are liable, the court must, upon the application of a person who has obtained leave to prosecute the bond or undertaking, made upon notice to the plaintiff's attorney, in each action then pending upon such bond or undertaking, and in each uncollected judgment recovered thereupon, direct and provide for the distribution of the money, collected out of the property of the sureties, among the persons in favor of whom the liabilities have accrued, in proportion to the amount which each one is entitled to recover; to be ascertained by a reference, or in such other manner as the court directs. For the purposes of the motion an order may be made by a judge, forbidding the payment to the plaintiff in any action, of the sum collected or to be collected by virtue of a judgment therein. But this section does not authorize the court to compel a plaintiff to refund any money, collected and received by him, in good faith, before service of notice of such an order.