message: Fix data race issues in app unit test
diff: @@ -2113,6 +2113,7 @@ TEST_CASE("app: sync integration", "[sync][app]") {
  SECTION("Invalid refresh token") {
  auto app_session = get_runtime_app_session("");
  + std::mutex mtx;
  auto verify_error_on_sync_with_invalid_refresh_token = [&](std::shared_ptr<SyncUser> user,
  Realm::Config config) {
  REQUIRE(user);
  @@ -2135,6 +2136,7 @@ TEST_CASE("app: sync integration", "[sync][app]") {
  std::atomic<bool> sync_error_handler_called{false};
  config.sync_config->error_handler = [&](std::shared_ptr<SyncSession>, SyncError error) {
  + std::lock_guard<std::mutex> lock(mtx);
  sync_error_handler_called.store(true);
  REQUIRE(error.error_code == sync::make_error_code(realm::sync::ProtocolError::bad_authentication));
  REQUIRE(error.message == "Unable to refresh the user access token.");
  @@ -2147,12 +2149,14 @@ TEST_CASE("app: sync integration", "[sync][app]") {
  {
  std::atomic<bool> called{false};
  session->wait_for_upload_completion([&](std::error_code err) {
  + std::lock_guard<std::mutex> lock(mtx);
  called.store(true);
  REQUIRE(err == app::make_error_code(realm::app::ServiceErrorCode::invalid_session));
  });
  timed_wait_for([&] {
  return called.load();
  });
  + std::lock_guard<std::mutex> lock(mtx);
  REQUIRE(called);
  }
  timed_wait_for([&] {
  @@ -2160,6 +2164,7 @@ TEST_CASE("app: sync integration", "[sync][app]") {
  });
  // the failed refresh logs out the user
  + std::lock_guard<std::mutex> lock(mtx);
  REQUIRE(!user->is_logged_in());
  };
  