Added test for StateHandler
Fixed bug in StateHandler