Unbreak testclient digest signature test
Handle cleanup better

So, the idea here is that if Close() is called, the 'done' channel is
closed so we can check that no more work should happen and return
io.EOF.

If the reader decides to bail (because of an error reading data from the
socket), it will close doneRead which will be checked whenever we're
waiting for a response from the reader.

Similarly, errors from the writer will close doneWrite.