Improved the lex.py

lex.py now has a lot of self contained tests. Some things like tests for duplicates still to be implemented.
Started the refactor of lex.

Broke read_tab and write_tab in the process.
Edited the tests

Cleaned up the tests, more readable and concise.
Improved lex.py readability & code

More renaming of variables.
Now uses doc-strings instead of doc-comments. Started splitting functions up.