Adds tests and fixes for zero-length keys.

Fixes #98.