Add a test for request timeout, and improve Function handling for timeout