Added check for headless run (tests)

Tests were failing (not even starting) for me without this change. I'm still spotting many failures but maybe it is a problem due to my environment (node 0.8.15). An alternative would be to use a navigator emulator like https://github.com/coolaj86/node-navigator