fixing the test suite and optimization