multi_name is a static string, fix test.

And initialize the string to empty. Cleaner and faster.
Move declaration where needed. Code clean-up.
New static routine to set the panel label.

Preparatory work for #9704.
New routine to update the panel header.

This routine update now the panel label. This is needed to be able to
display the proper multi-instance name when switching images.

Preparatory work for #9704.
When switching images make sure the header is updated.

This set the proper multi-name for the corresponding instance.

For #9704.
Make sure the duplicated module is saved in the history.

We do not want to save the new instance without having the previous
instance saved even when the first instance is not yet activated.

Fixes last issues reported in #9704.