Changed teardown error handling to be more reliable.
Adjusted a testcase for Python 3