Fix off-by-one heap corruption bug

Arrays are, of course, 0-indexed so while cut_len + 1 is the number of
allocated bytes, the last byte is accessed simply as trimmed[cut_len].

This didn't affect the tests on Linux or OS X, but did manifest in
larger data sets as the following error:

    *** glibc detected *** sickle: free(): invalid pointer: 0xDEADBEEF ***
Catch heap corruption in tests, even if the memory usage doesn't cause an abort
Move Ns to the cut boundaries so off-by-one bugs with trimming are detected

This catches other types of off-by-one bugs which might occur in the
N-handling code.
Merge branch 'looser-N-handling'