Fix bugs, refactor and cleanup user state/cookie code:

* Use "user state" rather than "cookie" when the implementation is
  not the main point.
* Fix issues with resumeTour and setTourCookie
* Factor common code out to updateUserStateForTour
* Move some code to internal.
* Use a helper method (parseUserState) to make convertToNewCookieFormat
  stateless again (as originally intended).
* Remove obsolete code from tests, and simplify slightly.

Change-Id: I8ef04e898d7af4fb499305a4bd73369016e97603
Merge "Fix bugs, refactor and cleanup user state/cookie code:"