Section 95. If two or more railroad corporations whose tracks cross each other at the same level agree to separate the grades, they may apply to the department which shall thereupon determine when, in what manner and by which corporation said work and each portion thereof shall be done, and shall apportion all charges and expenses caused by making such alterations and all future charges for keeping the necessary structures connected therewith in repair, among said corporations. For said purposes, the corporations may, under the direction of the department, make all necessary changes in the location, grade and construction of said railroads, and, so far as necessary, may take additional land therefor by eminent domain under chapter seventy-nine and may raise, lower or otherwise change any and all public ways; and in the exercise of said powers said corporations, and any person who sustains damage thereby, shall have all the rights, privileges and remedies, and be subject to all the duties, liabilities and restrictions provided by law in the case of land taken by railroad corporations.