Create tmp folder if it doesn't exists
Small refactoring

Change the way of building paths, separate helper methods from Document
class