refactor code to support AND, OR filter

- code cleanup
- support for AND and OR filter
- more tests for AND & OR filter