Add filter function and some tests