Add scrutinizer phpunit tests and refactoring