[2.2] Resolve two race conditions relating to HA lock sessions

- Add a check ensuring a slave commit has a running lock session when committing,
  or has explicitly opted out from having one.
- Move lock session management into its own class, where timeouts and concurrent
  access can be tested in isolation.
Because the message contains variable content (eg. the '1'), we'd need to use String.format() or some such, and I kind of like the clarity of the test saying "whatever method you're using to construct the message, it should come out looking like this". Also not a huge fan of package private things - I don't feel strongly about it, but I'd rather keep it the way it is now.