added more tests, fixed bugs in REST client