diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c
index 0017d786ceca7c3cc0ba9f06c63502c279a49248..da1dfdc84f16d3b92233356fb59bbb4003c5a59e 100644
--- a/coreapi/callbacks.c
+++ b/coreapi/callbacks.c
@@ -513,7 +513,7 @@ static void register_success(SalOp *op, bool_t registered) {
 	}
 
 	// If this register is a refresh sent by belle-sip, then move to the Refreshing register first
-	if (Account::toCpp(account)->getPreviousState() == LinphoneRegistrationOk) {
+	if (registered && Account::toCpp(account)->getPreviousState() == LinphoneRegistrationOk) {
 		Account::toCpp(account)->setState(LinphoneRegistrationRefreshing, "Registration refreshing");
 	}
 
diff --git a/src/account/account.cpp b/src/account/account.cpp
index 25769f680d40a9b5d82099c037872fc75abd375c..db2d6f1af3b0742ff40acc962039994b529c0b8a 100644
--- a/src/account/account.cpp
+++ b/src/account/account.cpp
@@ -199,7 +199,7 @@ bool Account::customContactChanged() {
 	if (mParams->mCustomContact == nullptr && mOldParams->mCustomContact == nullptr) return false;
 	if (mParams->mCustomContact != nullptr && mOldParams->mCustomContact == nullptr) return true;
 	if (mParams->mCustomContact == nullptr && mOldParams->mCustomContact != nullptr) return true;
-	return !((*mOldParams->mCustomContact) != (*mParams->mCustomContact));
+	return ((*mOldParams->mCustomContact) != (*mParams->mCustomContact));
 }
 
 void Account::applyParamsChanges() {
@@ -349,7 +349,7 @@ void Account::setState(LinphoneRegistrationState state, const std::string &messa
 	auto core = getCCore();
 	if (mState != state ||
 	    state == LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/
-		const auto identity = (mParams) ? mParams->getIdentity().c_str() : std::string();
+		const auto identity = (mParams) ? mParams->getIdentityAddress()->toString() : std::string();
 		if (!mParams) lWarning() << "AccountParams not set for Account [" << this->toC() << "]";
 		lInfo() << "Account [" << this << "] for identity [" << identity << "] moving from state ["
 		        << linphone_registration_state_to_string(mState) << "] to ["
@@ -618,7 +618,6 @@ std::list<SalAddress *> Account::getOtherContacts() {
 
 void Account::registerAccount() {
 	if (mParams->mRegisterEnabled) {
-
 		std::shared_ptr<Address> proxy = Address::create(mParams->mProxy);
 		if (proxy == nullptr) {
 			lError() << "Can't register LinphoneAccount [" << this << "] without a proxy";
@@ -650,6 +649,7 @@ void Account::registerAccount() {
 		} else {
 			setState(LinphoneRegistrationFailed, "Registration failed");
 		}
+
 		for (auto ct : otherContacts)
 			sal_address_unref(ct);
 	} else {
@@ -1012,8 +1012,8 @@ void Account::apply(LinphoneCore *lc) {
 	if (mDependency != nullptr) {
 		// disable register if master account is not yet registered
 		if (mDependency->mState != LinphoneRegistrationOk) {
-			if (mParams->mRegisterEnabled != FALSE) {
-				mRegisterChanged = TRUE;
+			if (mParams->mRegisterEnabled != false) {
+				mRegisterChanged = true;
 			}
 			// We do not call enableRegister on purpose here
 			// Explicitely disabling register on a dependent config puts it in a disabled state (see
diff --git a/tester/register_tester.c b/tester/register_tester.c
index 57647a30690b98f67850cc3de492d22b531cdc25..6d65fe908bfd9b415672a7135423c20e94119657 100644
--- a/tester/register_tester.c
+++ b/tester/register_tester.c
@@ -268,6 +268,9 @@ static void register_with_custom_headers(void) {
 	value = linphone_proxy_config_get_custom_header(cfg, "Server");
 	BC_ASSERT_PTR_NOT_NULL(value);
 	if (value) BC_ASSERT_PTR_NOT_NULL(strstr(value, "Flexisip"));
+
+	linphone_core_clear_accounts(marie->lc);
+	wait_for(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationCleared, 1);
 	linphone_core_manager_destroy(marie);
 }
 
diff --git a/tester/tester.c b/tester/tester.c
index 40a14661a605ea9c036fa3cbf22ab54b90eba683..54271a3fecfe06f57e41bab8d8aa95e6f02a0fe4 100644
--- a/tester/tester.c
+++ b/tester/tester.c
@@ -2749,6 +2749,7 @@ static void check_orphan_nat_policy_section(LinphoneCoreManager *mgr) {
 
 void linphone_core_manager_stop(LinphoneCoreManager *mgr) {
 	if (mgr->lc) {
+		int previousNbRegistrationCleared = mgr->stat.number_of_LinphoneRegistrationCleared;
 		const char *record_file = linphone_core_get_record_file(mgr->lc);
 		if (!liblinphone_tester_keep_record_files && record_file && bctbx_file_exist(record_file) == 0) {
 			if ((bc_get_number_of_failures() - mgr->number_of_bcunit_error_at_creation) > 0) {
@@ -2759,6 +2760,8 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr) {
 		}
 
 		linphone_core_stop(mgr->lc);
+		wait_for_until(mgr->lc, NULL, &mgr->stat.number_of_LinphoneRegistrationCleared,
+		               previousNbRegistrationCleared + 1, 2000);
 		check_orphan_nat_policy_section(mgr);
 		linphone_core_unref(mgr->lc);
 		mgr->lc = NULL;