hide state implementation details from state context

* refactor StateFactory to make State from StateType
* cleanup and merged tests