Refactored unit tests to support Python 3, fixed Python 3 issues'