Port the test code from python.
Remove the sleep. A call to shutdown() should finish shutting down all endpoints before returning.
Add a test that ensures that requests are serviced before shutdown() returns.
Enhance shutdown and threading machinery, so that requests are completed before shutdown() returns.