Fix tests and a few mistakes