Improvement to tests

Several random things I've added to unittests and regressions. I'm not done with the `optdone` stuff for #103, but I made some major changes by using the generic classes everywhere (so much less code!) and I wnated to get those commits in master.