NegateSignatureS is called with a signature which has not yet had the hashtype appended to it, yet the function assumed a hashtype was there and was incorrectly saving and then appending the last byte of its input (ie the last byte of the original S instead of a hashtype).
Only one pair of the test scripts was triggering this bug ("P2PK with high S"), which was actually causing the invalid version of the test to fail in the wrong place -- it was failing in the IsValidSignatureEncoding function rather than further down in IsLowDERSignature where the S value is checked. Fixing NegateSignatureS causes this test to change so that IsLowDERSignature is now being tested as I believe was intended.
Fixing that test resulted in there no longer being code coverage for the check in IsValidSignatureEncoding relating to extra bytes after the S, so the second commit here adds a pair of tests to exercise that check.