Modify testsuite and scripts to run on OSX and FreeBSD

Review 467 by @mlucy
Closes #653