Modify testsuite and scripts to run on OSX and FreeBSD (#653)