refined shutdown mechanism and updated test client to handle connection
loss