Add condition to query test

Signed-off-by: Kirill Zotkin <kirillzotkin@gmail.com>