Add test for lexer errors

This is a test case for code from #4. I've also added separate exception class for lexer errors to make testing more straightforward.