tests.py: Fix for compatibility with Python 3.x