Improvements to test.py and logging