PHPUnit tests and a small fix