Polished test.py, enabled specifying output dir.