cleanup method

This PR helps to make tests more reliable. The temp directory should be cleared *before* running a test: If a test failed, you check the temp directory if something wrong there.

Based upon work in #164