If the court finds that a part of the judgment has been actually paid to or for the commonwealth upon the recognizance or judgment and orders the judgment to be reversed or entered for a less amount than has been so actually paid, it may order the amount of the difference between the payment and the new judgment to be repaid to the person who made the payment or to his legal representatives. The state treasurer shall, upon presentation of a copy of the order certified by the clerk of the court, make said repayment. If, upon such petition, the review is not granted or the original judgment is not altered, the court may award reasonable costs against the petitioner.
Mass. Gen. Laws ch. 276, § 78