running http call in a thread and adding a way to join the thread in tests