Update tests and add code for finding states in recursive state machines