Fixing deserialization and adding unit test

There was a bug in the deserialization that didn't manifest itself
with the existing unit test.  I added another unit test that
showed the problem and fixed the code in the same patch.
Merge pull request #3 from radostyle/master

Fixing deserialization and adding unit test