Fix Python 3 syntax errors in tests.py