Make behavior of getStatesForPipelineId more consistent

It now returns an unmodifiable list. Earlier, if the state existed, it would pass a direct reference to the list which could be modified by the callee. If not, it would create an empty state list but not store its reference in the data map.