A court in a suit to foreclose the lien shall render judgment for the amount due and order to be sold as much of the railroad right-of-way and equipment as is necessary to satisfy the judgment only if:
(1) the work was performed at the instance of the railroad company or the company's agent, contractor, or subcontractor; and
(2) the amount claimed is due.