Environment filtering for #781
Added a test for environment filtering.