Throw exception when unable to connect, with test.