Define _matchMedia wrapper earlier

The unit test stub didn't work because the _matchMedia wrapper
was defined too late.

This fix defines it earlier.