Refactor temp directory methods into helper module