Invalid syntax tests

Add tests for invalid syntax. 
Add bail out code to stop processing when invalid syntax is encountered