Fix bug in filter, add tests

- Fix a bug that prevented `filter` from filtering when given both a predicate and a collection.
- Add unit tests for `filter`.