add unit tests for dynamic query