Add readstate helper function and test in action