Move check identifier from extend to service definition

Move the check of the identifier to extend in the closure to allowed to extends a service is not defined yet.