hwrt/create_pfiles.py: refactoring for easier testing