Set version number to 4.0.0+
Detect binary attachments better

This fix eliminates a false test failure on some platforms and makes
the binary test work properly whether characters with the high bit
set, when treated as integers, are negative or not.