First round of code cleanup
Start of code cleanup for formatter

flake8 likes it.
Refactor code, extract methods on build_table
Add unit tests for formatter
Add unittests for formatter