Refactored lexer.rb and added more tests