Fix bugs in intersection() and add more tests