Added tests for state classes.
Final implementation.
Type checker fixes.