Lexer refactor to use funcs, better test coverage