fix some bugs and tests for annotations