add more tests and refactor http call