client layer improved, phpunit tests added