addition of further helper functions and tests for stat based query generation method