fixed key serialization
added test
Merge pull request #557 from MaksSlesarenko/fix-for-date-primary-key

fixed key serialization