CA-148137: don't free NBD client if there are pending requests, plus unit tests

This patch fixes a bug where we blindly deallocate the NBD client without
checking whether there are pending requests. We address this issue by
marking the client as "dead" and letting the last pending request to
complete to deallocate it.