This adds some initial unit tests for file filtering and fixes some simple bugs in filter application.