maint/fix facts environment ordering

this fixes an issue with ordering by environment on the facts endpoint and
patches the corresponding blind spot in our tests.