plumbing: add unit test for the TagManager class, and correct some bugs in the model.