added unit tests for TagSet.encode/decode (and fixed a problem with them)