Properly closes logging and puts test files in proer places

Problems probably only visible on Windows.