Fix bug in profile name handling exposed by tests

The variable being used for setting the profile name was old...