Refactor authentication filters for unit testing.