Separated from pwf.php

* Added basic tests