Fix tests
Add documentation
Python 3 compat and code cleanup