refactored request method and wrote tests