fix bug in token deserialization

  * clean up code a bit
Merge pull request #13 from varjoranta/master

fix bug in token deserialization