Refactoring, setting phpunit, fixes and DB