Filter mostly fixed and added unit test for filter