[tests] Use mprotect to verify no buffer overflows

This also simplifies the test code a bit.