Refactoring and add PHPUnit testing functionality
Add PHPUnit tests