Add filter code and unit tests