Two bugs fixed in QDigest and better test for it.

Thanks to Michael Yahalom for pointing out the bugs.