edit script
remove dead code
edit tests
rewrite some tests