Be more specific in the type mismatch error message.
Fix tests after changing the error message.
Use sizeof(uintptr_t) dependent magic number and mask.
Compatibility workarounds for Lua 5.1, enable tests for 5.1, 5.2, JIT.