add more unit tests, fix uniq problem