add filter tests; some code cleanup