use generate_bell for det_perm; work with Sparse, too

self -> M

simplify=False is used in the tests. Without this, the
times taken increases significantly. (e.g. 48 seconds
instead of 2 seconds for the system of issue 2015.)

some refactoring of code was also done.