Utils.states - doctest completeness and bugfix

Increase doctest coverage to 100%

Fix bugs that were discovered during testing