safer for python3 and corrected unittests