Line counting for TR optimizer tests

@mflatt: I'm not sure on the first commit if it should be returning 0 or #f. It also looks like there are 2 other cases in the file where this could be a problem, should they also have a similar check?