Fix tmp directory creation and directory change for integration tests