bin/test.py: refactored to use temporary file