Changed the classification algorithm to also use the uppermost class.

Added range testing to the unit tests, and found a bug in that ranges
can sometimes be negative.  Investigating.
This change properly handles cascading classes.

If moving the neighbor up or down cascades into the neighbor's neighbor,
fixes them too.