Don't write test files to /private/tmp since it's mac specific.

Set HOMEBREW_PREFIX to /tmp/testbrew/prefix, and use it in place of hardcoded paths in tests. This prevents errors running tests on travis-ci.