refactoring (logging); added test case for create_pfiles