daemon initialization refactoring, test fixes