Section 106. If, upon application to the county commissioners by the board of aldermen or selectmen, and after notice to the corporation which owns or operates a railroad, and a hearing, it appears that the railroad so crosses a public way other than a state highway as to obstruct it, contrary to section ninety-seven, or to a decree made under section one hundred, or that the corporation refuses or neglects to keep a bridge or other structure required or necessary at such crossing in proper repair, the county commissioners may make a decree prescribing what repairs shall be made by the corporation at the crossing, and the time within which they shall be made. A commission of three disinterested persons, appointed as provided in section sixty-two of chapter one hundred and fifty-nine, shall determine which party shall carry such decision into effect and which party shall pay the charges and expenses of making such repairs and the future charges for keeping such bridge or crossing and the approaches thereto in repair, as well as the costs of the application to the county commissioners, or the department, and of the hearing before said commission; and it may apportion all such charges, expenses and costs between the railroad corporation, the railway company having tracks on said way, and the counties, cities or towns where said crossing is situated and other cities and towns which may be specially benefited; provided, that the parties in interest may waive the appointment of the commission and determine the foregoing by written agreement to be filed in the proceeding. If a railway company is authorized to lay and use tracks upon any bridge in a highway built, repaired or altered as above provided for, or the approaches to which are altered or improved as above provided for, the said commission shall determine what part of the charges and expenses of making such changes or improvements, or of keeping such bridge or crossing and approaches in good condition, shall be paid by said railway company. They may further order the corporation to give security, as provided in section one hundred, for the faithful performance of the requirements of the decree and for the indemnity of the city or town upon a failure in such performance.