enforce the max key size with a runtime check
fix whitespace
add test for long database key
include sys/stat.h to fix warning on gcc 4.7
make conditional statement more readable