refactored StateView to work with stateviews + wrote tests