[DependencyInjection] Tweaked factories

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #12008
| License       | MIT
| Doc PR        | n/a

There are some issues with new service factories:
 * `ContainerBuilder` cannot instantiate service from factory (i.e. currently it works for dumped code only)
 * Dumped code sometimes is invalid (anonymous services as factories, factories without arguments)