isMongosConnection NPE handling

I have faced NPE in isMongosConnection method at Mongo.class. Added code to handle it in polite manner and a unit test to illustrate the case. The problem is that it's not always reproduced locally, I'd even say that there has to happen some integration magic before it is reproduced. 

Use case is taken from Fongo project.