add test for and/distinct/join and fix bug