Encode queries in tests