fix errors and test