query must contain val1 and val2..
Check for val1 and val2 individually

Part of #259. This prevents us from getting an otherwise unhandled
exception at least although it doesn't fix the whole problem.