When running unittests don't write to outside the build dir.

This fixes: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=743108