Query: Fixed stats folding method for small n.

Added rigorous test cases for statistics-gathering class.