I think my SESSION_COUNTER is now redundant.  If I remember, it's only ever used inside unittest, but your session counting is better.  Maybe remove mine and update unittest to check yours instead?