Move the hashlib wrapper into utils.
Workaround for python3

Apparently in python3 exception variables get unbound when leaving
the except: scope.
Wrap the send() method to ensure we send bytes and not text.
Ensure that bytes are bytes.
We expect binary data back, not text.
Update the integration tests to expect bytes.