Fix tests on mac

Submitting the changes as a feature branch as requested.

These changes fix the tests to be more general and work on mac and linux.