tests and some fixes