(#2698) - fix attachment md5 encoding

This also significantly augments our test coverage,
because we're now testing that the md5sum we get
back from our md5 algorithm is exactly the same as
CouchDB's. The only exception if for plaintext, which
CouchDB hashes differently due to using ICU instead of
ASCII.