Fixed wraparound bugs in SequenceCounter

SequenceCounter appeared to be breaking when the short id wrapped
around. It appeared to use the xor operator where a 'raised to'
was intended, and could become stuck in a bad state because
'lastPhysicalSequenceNumber' never ever decreased.