port to py3 + unittests