Fix bugs with allow-duplicate-installations-on-an-agent.

- Make sure that the config setting is respected everywhere.
- If less agents than requested installs are present and duplicate installation is allowed, install
  more than one instance of a service per agent.
Configs are mutable, so the values should be extracted and stored in the constructor