refactoring in REST client + fix in units tests