Added tests, fixed some errors.
Fix more filter bugs