Make the timeout parameter customizable
Update tests for the new timeout parameter
Add tests for error cases