Finishing Python 3 port, unit tests pass both in Python 2 and 3