Fixes semantic tagger and adds tests for it