fix a seq number wraparound case

and add the corresponding test case.
while i'm here, use assertEqual macro.