Copy Python 2 test code changes to Python 3 files