[DependencyInjection] fixed management of scoped services with an invalid behavior set to null

The optimization for references has been removed as it does not take
scopes into account.