implementing state API, more unit test debugging