Refactor and test lex API. Simplify standalone use of lex module. Fix couple of bugs. Beautify test code.

### Lex:
* [will fill]

### Lex test:
* [will fill]
Frankly, they are kinda useless. If something goes wrong, Python's runtime will print an informative stacktrace. Also, `self.verbose` should have one use only.