Fixed queries test and made parent reference use cache.