Fix off by one errors with TestParser, and refactor associated tests