parentheses fix and query generator tests

Signed-off-by: Kamil Neczaj <kamil.neczaj@cern.ch>