Add test for complicated query.