Fixes a wrong select for scopes if the state machines attribute_name is set to something other than the default (Fix picked from `phillipp`s PR).