fix sedstacker code and get test_sed.py to pass

(partial commit, more tests need to be uncommented
and fixed)