Refactor code. OOP.
Fix pep8
Make the code compatible with python3 and fix a typo

typo: format
Add tests