Be more cautious when testing for OpenLayers

Tests crashed in Chrome without the window notation.