timeout-test: fix on very slow machines

On slow old machines, the TLS handshake when making an https request
can take longer than 1 second, which meant that even the "fast" https
requests were hitting the 1-second timeout and failing.

Fix this by making the timeouts longer. However, we don't want to do
that unless absolutely necessary, since the test has to hit this
timeout multiple times, and the test already takes 10 seconds to run
with the 1-second timeout. So check how long it takes to make a single
https request, and only slow down the rest of the tests if it looks
like it will be needed.

Also fix an unrelated bug, where the "session did/didn't close
connection" check could fail if the same memory location got used for
the first and second sockets.

https://bugzilla.gnome.org/show_bug.cgi?id=660581