some work on tests and some fixes