Fix and test for USERGRID-49

This is a fix and associated test for USERGRID-49.