[loader] Test correct attach order of optional dependencies