fixed bugs in parser to ensure it fails with an appropriate error message for failure cases in the new tests
all new tests implemented (parser.tests)