Advanced query tests