add trailing space to AND concat
fix wrong AND for query
fix timerange tests not actually being timerange tests