New tests and some fixes