Fix bug where you couldn't run on a line that wasn't a statement

A line such as a comment line or a blank line that isn't part of a statement wouldn't properly run that test file. So this PR will check up the file until the closest method definition it knows about. I also added some tests.