Enhance filter to work with environment dependencies and improve test coverage overall