Add a mock test server using rhea library. It has a container object that can act as a server as well. Take a look at rhea's tests around disconnects and detach and try adding similar tests in this library to ensure that we recover the links and the connection nicely.