[WIP] Introduce unit testing to the project. Refactor lexer and type modules. Fix various bugs.

...will fill...