make a long running worker and kill it after some time from the test case, the function at exit should be called. Disconnect is harder to test, as it depends on the process management of the operating system.