New tests and various fixes all over the place.