Testing for encode and decode for restoring and saving state