Fix bug when destroying
add iOS tests