Add code to clean up when test_nested.py is run by python 3

Third follow up for #41.