Fix try/except in test runner for Python3 compatibility