Update filter functionality and add tests