template: add tests on subdirectory existence

Subdirectories are optionnal and a test is performed for each subdirectory.