Prevent using memory excessively in tests for Queries