Create the wrapper app before building the children.

Reorganize the code so that the wrapper app is created (if necessary) before initializing the template so that nested entity creation doesn't throw exceptions. The existence of the root app is mandatory.
The main change is the check whether the single serviceType is an application (see isSingleApp) before having it instantiated.