fix generate_bell

This fixes the generate_bell routine. The tests did not catch the fact that for n > 4 the correct number of permutations were returned, but many were duplicates.

This fixes issue 2693.