Adding test cases and correcting mistakes