Fix index out of bounds for key-value with no value

Fixes gh-249