Minor refactoring plus improved testing of nibbles.

Using only one test point failed to test both sides of the nibble
functions, so I added another test point.  I was doing the same math a
number of different places so I refactored the code.