Refactoring simple http client