Added support for query timeout (maxTime).
Fixed comments.
[Issue 634] Merged changes that fixes issue #634. Added unit test for the changes, and backed out the changed to countAll that are not necessary.