fix memory leak and add new test to check that linphone_core_destroy() sends BYE for unterminated calls.