Add test case for first() and last() query