Fixes to api filters (broken during model refactor)

Split filters out into a separate module.

* Unit tests in test_filter
* End to end test in test_api