Make all tests go via main entry method

Fixes a few bugs
Merge pull request #36 from ForbesLindesay/test-better

Make all tests go via main entry method