Make error codes consistent

All errors have the suffix _ERROR.
Prevent segfaults when calling Error on a closed/damaged db
Transaction and Iterator guards

This prevents segfaults when attempting to iterate through a closed db.
Handle NULLs in Iterator start/end

We were trying to `strlen(NULL)`, which caused segvs..
Refactor tests