Refactor parser testing code