Refactor filter.py, add first test case