Fix internal consistency check in sorted_spaces

The consistency check implementation was assuming that states
were based on a map. Fixed.