add some tests for dynamically ordered query