[4.0] Made peer verification more secure

Since this was such an important security update to 4.1, I updated 4.0 too. Can you tag this as `4.0.13`? :)

Had a hellofa time getting the 4.0 tests to pass. Lol.