adding test cases for query and refactory nested query with results collection