updated api unit tests and corrected cleanup