Added StateController class and a few unit tests