Added more tests including statechart mechanics. Fixed a few bugs.