fix some bugs and add test for unique queue