Fix and improve the test suite