refactor code when updating filters and fix tests