Improved SM life-cycle: added and fixed tests; forcing stop on set_state(:error)