added proper unit tests, updated files to work with PHPUnit