Whenever any action at law or in equity is brought in any court in this state questioning directly or indirectly the existence of any condition or thing precedent to, or the validity of any action taken or proposed to be taken, by any public body or its officers or agents in the course of the authorization or sale, issuance or delivery of bonds, the making of a contract for public improvement or the validity of any proceeding to alter the organization of a school district in any manner, such public body may move the court for an order requiring the party, or parties, bringing such action to file a surety bond as hereinafter set forth. Three days' written notice of such motion shall be given. If the public body is not a party to the action, but if it deems that such action be injurious to the public interest and to the taxpayers, such public body may intervene or appear specially for the purpose of making such motion. If the court determines that loss or damage to the public or taxpayers may result from the pendency of the action or proceeding, the court may require such party, or parties, to file a surety bond, which shall be approved by the court, in such amount as the court may determine. The court must also consider whether the action presents substantial constitutional issues or substantial issues of statutory construction, and the likelihood of a party prevailing on these issues, when determining the amount of a bond and whether a bond should be required under this section or section 473.675. Such bond shall be conditioned for payment to the public body of any loss or damage which may be caused to the public body or taxpayers by such delay, to the extent of the penal sum of such bond, if such party, or parties, shall not prevail therein. If such surety bond is not filed within a reasonable time allowed therefor by the court, the action shall be dismissed with prejudice. If such party, or parties, file a bond as herein required and prevail in the action, any premium paid on the bond shall be repaid by or taxed against the public body.