Correcting middleware tests and making correct env change