Add negative tests for updated read/writeElement.

This commit adds tests for the error paths in the updated readElement and
writeElement functions.

This brings the test coverage back up to 100%.