Refactored REST client and unit tests.