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.
Merged pull request #475
Making test cases more portable, especially handy for Jenkins.
Merged pull request #476