Set proper size for key-vaue array in MapCursorImpl.

This addresses the issue reported in #149, including both a specific unit test and a bigger functional test.

Apologies for my Scala - I'm not well-versed in the language.  Suggestions for improvement welcome.