Make sure the live server blocks until it's available

Currently the problem is that for our big project the live server takes more than a second to become available. This little loop with a maximum timeout of 5 seconds makes sure we block for longer if necessary. Behavior doesn't change if your server only needs 1 second. Tests pass.