Better cleanup of temporary files in tests

Not sure I've squashed them all, but this is a start
>  This is actually not ok sorry

https://github.com/ambiata/ivory/pull/464