Add parser tests, small parser refactor