Adding an init method to Parser for reseting the state before each parse. Refactoring test cases.