refactoring the http client code and add http client junit tests