Improved clientDisconnected tests.
Improved client close logic.

Refers #135.