Use headless env. for testing
Merge PR #1397 by @msteiger - headless unit testing fix