Fix and improve tests.