Fixed prototypes and return values, segfaults on invalid hash and add a test case.

I decided to go for a warning as it's not really an exceptional state, and it's
how MongoClient::close() does it as well.