Add some integration tests and fix bugs

- Fixed bugs in merge_states and equiv where cyclical structures
  were not handled correctly.
- Fixed bug in minimize where not all distinct states were being
  marked
- Fixed bug in minimize where cases in which there were more than
  two non-distinct states were creating multiple replacement
  states