Changing middleware to plain filter
Unittests now working as expected
Some small flake8 fixes