diff --git a/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java b/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java
index d3b8b35..7068da4 100644
--- a/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java
+++ b/policy-agent/src/main/java/org/oransc/policyagent/tasks/StartupService.java
@@ -22,6 +22,7 @@
 
 import org.oransc.policyagent.clients.A1ClientFactory;
 import org.oransc.policyagent.configuration.ApplicationConfig;
+import org.oransc.policyagent.configuration.ApplicationConfig.RicConfigUpdate;
 import org.oransc.policyagent.configuration.RicConfig;
 import org.oransc.policyagent.repository.Policies;
 import org.oransc.policyagent.repository.PolicyTypes;
@@ -78,19 +79,23 @@
     }
 
     @Override
-    public void onRicConfigUpdate(RicConfig ricConfig, ApplicationConfig.RicConfigUpdate event) {
+    public void onRicConfigUpdate(RicConfig ricConfig, RicConfigUpdate event) {
         synchronized (this.rics) {
-            if (event.equals(ApplicationConfig.RicConfigUpdate.ADDED)
-                || event.equals(ApplicationConfig.RicConfigUpdate.CHANGED)) {
-                Ric ric = new Ric(ricConfig);
-                rics.put(ric);
-                RicSynchronizationTask synchronizationTask =
-                    new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
-                synchronizationTask.run(ric);
-            } else if (event.equals(ApplicationConfig.RicConfigUpdate.REMOVED)) {
-                rics.remove(ricConfig.name());
-            } else {
-                logger.debug("Unhandled event: {}", event);
+            switch (event) {
+                case ADDED:
+                case CHANGED:
+                    Ric ric = new Ric(ricConfig);
+                    rics.put(ric);
+                    RicSynchronizationTask synchronizationTask = createSynchronizationTask();
+                    synchronizationTask.run(ric);
+                    break;
+
+                case REMOVED:
+                    rics.remove(ricConfig.name());
+                    break;
+
+                default:
+                    logger.error("Unhandled ric event: {}", event);
             }
         }
     }
@@ -104,4 +109,7 @@
         refreshConfigTask.start();
     }
 
+    RicSynchronizationTask createSynchronizationTask() {
+        return new RicSynchronizationTask(a1ClientFactory, policyTypes, policies, services);
+    }
 }
diff --git a/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java b/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java
index eeecc1c..5590c5e 100644
--- a/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java
+++ b/policy-agent/src/test/java/org/oransc/policyagent/tasks/StartupServiceTest.java
@@ -20,194 +20,118 @@
 
 package org.oransc.policyagent.tasks;
 
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-import static org.oransc.policyagent.repository.Ric.RicState.IDLE;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
 
-import com.google.common.collect.ImmutableList;
-
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Vector;
 
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
 import org.mockito.junit.jupiter.MockitoExtension;
-import org.oransc.policyagent.clients.A1Client;
-import org.oransc.policyagent.clients.A1ClientFactory;
 import org.oransc.policyagent.configuration.ApplicationConfig;
 import org.oransc.policyagent.configuration.ImmutableRicConfig;
 import org.oransc.policyagent.configuration.RicConfig;
-import org.oransc.policyagent.repository.Policies;
-import org.oransc.policyagent.repository.Policy;
-import org.oransc.policyagent.repository.PolicyType;
-import org.oransc.policyagent.repository.PolicyTypes;
 import org.oransc.policyagent.repository.Ric;
-import org.oransc.policyagent.repository.Ric.RicState;
 import org.oransc.policyagent.repository.Rics;
-import org.oransc.policyagent.repository.Services;
-
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
 
 @ExtendWith(MockitoExtension.class)
 public class StartupServiceTest {
     private static final String FIRST_RIC_NAME = "first";
-    private static final String FIRST_RIC_URL = "firstUrl";
     private static final String SECOND_RIC_NAME = "second";
-    private static final String SECOND_RIC_URL = "secondUrl";
-    private static final String MANAGED_NODE_A = "nodeA";
-    private static final String MANAGED_NODE_B = "nodeB";
-    private static final String MANAGED_NODE_C = "nodeC";
 
-    private static final String POLICY_TYPE_1_NAME = "type1";
-    private static final String POLICY_TYPE_2_NAME = "type2";
-
+    @Mock
     ApplicationConfig appConfigMock;
+    @Mock
     RefreshConfigTask refreshTaskMock;
-
-    A1Client a1ClientMock;
-    A1ClientFactory a1ClientFactory;
-
-    @BeforeEach
-    public void init() throws Exception {
-        a1ClientMock = mock(A1Client.class);
-        a1ClientFactory = mock(A1ClientFactory.class);
-        appConfigMock = mock(ApplicationConfig.class);
-        refreshTaskMock = mock(RefreshConfigTask.class);
-        doReturn(Mono.just(a1ClientMock)).when(a1ClientFactory).createA1Client(any());
-    }
+    @Mock
+    RicSynchronizationTask synchronizationTaskMock;
 
     @Test
-    public void startupAndAllOk_thenRicsAreConfiguredInRepository() {
-        Mono<List<String>> policyTypes1 = Mono.just(Arrays.asList(POLICY_TYPE_1_NAME));
-        Mono<List<String>> policyTypes2 = Mono.just(Arrays.asList(POLICY_TYPE_1_NAME, POLICY_TYPE_2_NAME));
-        doReturn(policyTypes1, policyTypes2).when(a1ClientMock).getPolicyTypeIdentities();
-        doReturn(Mono.just("Schema")).when(a1ClientMock).getPolicyTypeSchema(anyString());
-        doReturn(Flux.empty()).when(a1ClientMock).deleteAllPolicies();
-
-        Rics rics = new Rics();
-        PolicyTypes policyTypes = new PolicyTypes();
-        StartupService serviceUnderTest = new StartupService(appConfigMock, refreshTaskMock, rics, policyTypes,
-            a1ClientFactory, new Policies(), new Services());
+    public void startup_thenServiceIsAddedAsObeserverAndRefreshIsStarted() {
+        StartupService serviceUnderTest =
+            new StartupService(appConfigMock, refreshTaskMock, null, null, null, null, null);
 
         serviceUnderTest.startup();
 
-        serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, FIRST_RIC_URL, MANAGED_NODE_A),
-            ApplicationConfig.RicConfigUpdate.ADDED);
-        serviceUnderTest.onRicConfigUpdate(
-            getRicConfig(SECOND_RIC_NAME, SECOND_RIC_URL, MANAGED_NODE_B, MANAGED_NODE_C),
-            ApplicationConfig.RicConfigUpdate.ADDED);
+        verify(appConfigMock).addObserver(serviceUnderTest);
+        verify(refreshTaskMock).start();
+    }
+
+    @Test
+    public void twoNewRicsAddedToConfiguration_thenSynchronizationIsStartedAndTwoRicsAreAddedInRepository() {
+
+        Rics rics = new Rics();
+        StartupService serviceUnderTest =
+            spy(new StartupService(appConfigMock, refreshTaskMock, rics, null, null, null, null));
+
+        doReturn(synchronizationTaskMock).when(serviceUnderTest).createSynchronizationTask();
+
+        serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME), ApplicationConfig.RicConfigUpdate.ADDED);
+        serviceUnderTest.onRicConfigUpdate(getRicConfig(SECOND_RIC_NAME), ApplicationConfig.RicConfigUpdate.ADDED);
 
         Ric firstRic = rics.get(FIRST_RIC_NAME);
-        Ric secondRic = rics.get(SECOND_RIC_NAME);
-        await().untilAsserted(() -> assertThat(firstRic.getState()).isEqualTo(IDLE));
-        await().untilAsserted(() -> assertThat(secondRic.getState()).isEqualTo(IDLE));
-
-        assertTrue(policyTypes.contains(POLICY_TYPE_1_NAME), POLICY_TYPE_1_NAME + " not added to PolicyTypes.");
-        assertTrue(policyTypes.contains(POLICY_TYPE_2_NAME), POLICY_TYPE_2_NAME + " not added to PolicyTypes.");
-        assertEquals(2, rics.size(), "Correct number of Rics not added to Rics");
-
-        assertNotNull(firstRic, "Ric " + FIRST_RIC_NAME + " not added to repository");
         assertEquals(FIRST_RIC_NAME, firstRic.name(), FIRST_RIC_NAME + " not added to Rics");
+        verify(synchronizationTaskMock, times(1)).run(firstRic);
 
-        assertEquals(1, firstRic.getSupportedPolicyTypes().size(),
-            "Not correct no of types supported for ric " + FIRST_RIC_NAME);
-        assertTrue(firstRic.isSupportingType(POLICY_TYPE_1_NAME),
-            POLICY_TYPE_1_NAME + " not supported by ric " + FIRST_RIC_NAME);
-        assertEquals(1, firstRic.getManagedElementIds().size(),
-            "Not correct no of managed nodes for ric " + FIRST_RIC_NAME);
-        assertTrue(firstRic.isManaging(MANAGED_NODE_A), MANAGED_NODE_A + " not managed by ric " + FIRST_RIC_NAME);
-
-        assertNotNull(secondRic, "Ric " + SECOND_RIC_NAME + " not added to repository");
+        Ric secondRic = rics.get(SECOND_RIC_NAME);
         assertEquals(SECOND_RIC_NAME, secondRic.name(), SECOND_RIC_NAME + " not added to Rics");
-        assertEquals(2, secondRic.getSupportedPolicyTypes().size(),
-            "Not correct no of types supported for ric " + SECOND_RIC_NAME);
-        assertTrue(secondRic.isSupportingType(POLICY_TYPE_1_NAME),
-            POLICY_TYPE_1_NAME + " not supported by ric " + SECOND_RIC_NAME);
-        assertTrue(secondRic.isSupportingType(POLICY_TYPE_2_NAME),
-            POLICY_TYPE_2_NAME + " not supported by ric " + SECOND_RIC_NAME);
-        assertEquals(2, secondRic.getManagedElementIds().size(),
-            "Not correct no of managed nodes for ric " + SECOND_RIC_NAME);
-        assertTrue(secondRic.isManaging(MANAGED_NODE_B), MANAGED_NODE_B + " not managed by ric " + SECOND_RIC_NAME);
-        assertTrue(secondRic.isManaging(MANAGED_NODE_C), MANAGED_NODE_C + " not managed by ric " + SECOND_RIC_NAME);
+        verify(synchronizationTaskMock).run(secondRic);
     }
 
     @Test
-    public void startupAndUnableToConnectToGetTypes_thenRicStateSetToUndefined() {
-        Mono<?> error = Mono.error(new Exception("Unable to contact ric."));
-        doReturn(error, error).when(a1ClientMock).getPolicyTypeIdentities();
-
+    public void oneRicIsChanged_thenSynchronizationIsStartedAndRicIsUpdatedInRepository() {
         Rics rics = new Rics();
-        PolicyTypes policyTypes = new PolicyTypes();
-        StartupService serviceUnderTest = new StartupService(appConfigMock, refreshTaskMock, rics, policyTypes,
-            a1ClientFactory, new Policies(), new Services());
+        Ric originalRic = new Ric(getRicConfig(FIRST_RIC_NAME, "managedElement1"));
+        rics.put(originalRic);
 
-        serviceUnderTest.startup();
-        serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, FIRST_RIC_URL, MANAGED_NODE_A),
-            ApplicationConfig.RicConfigUpdate.ADDED);
+        StartupService serviceUnderTest =
+            spy(new StartupService(appConfigMock, refreshTaskMock, rics, null, null, null, null));
 
-        assertEquals(RicState.UNDEFINED, rics.get(FIRST_RIC_NAME).getState(),
-            "Not correct state for " + FIRST_RIC_NAME);
+        doReturn(synchronizationTaskMock).when(serviceUnderTest).createSynchronizationTask();
+
+        String updatedManagedElementName = "managedElement2";
+        serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, updatedManagedElementName),
+            ApplicationConfig.RicConfigUpdate.CHANGED);
+
+        Ric firstRic = rics.get(FIRST_RIC_NAME);
+        assertEquals(FIRST_RIC_NAME, firstRic.name(), FIRST_RIC_NAME + " not added to Rics");
+        assertTrue(firstRic.getManagedElementIds().contains(updatedManagedElementName), "Ric not updated");
+        verify(synchronizationTaskMock).run(firstRic);
     }
 
     @Test
-    public void startupAndUnableToConnectToDeleteAllPolicies_thenRicStateSetToUndefined() {
+    public void oneRicIsRemoved_thenNoSynchronizationIsStartedAndRicIsDeletedFromRepository() {
+        Rics rics = new Rics();
+        RicConfig ricConfig = getRicConfig(FIRST_RIC_NAME);
+        rics.put(new Ric(ricConfig));
 
-        Mono<List<String>> policyTypes = Mono.just(Arrays.asList(POLICY_TYPE_1_NAME));
-        when(a1ClientMock.getPolicyTypeIdentities()).thenReturn(policyTypes);
-        when(a1ClientMock.getPolicyTypeSchema(anyString())).thenReturn(Mono.just("Schema"));
-        Flux<?> error = Flux.error(new Exception("Unable to contact ric."));
-        doReturn(error).when(a1ClientMock).deleteAllPolicies();
+        StartupService serviceUnderTest =
+            new StartupService(appConfigMock, refreshTaskMock, rics, null, null, null, null);
 
-        RicConfig ricConfig = mock(RicConfig.class);
-        when(ricConfig.name()).thenReturn(FIRST_RIC_NAME);
-        when(ricConfig.managedElementIds()).thenReturn(ImmutableList.copyOf(Collections.emptyList()));
-        Ric ric = new Ric(ricConfig);
+        serviceUnderTest.onRicConfigUpdate(ricConfig, ApplicationConfig.RicConfigUpdate.REMOVED);
 
-        PolicyType policyType = mock(PolicyType.class);
-        when(policyType.name()).thenReturn(POLICY_TYPE_1_NAME);
-
-        Policy policy = mock(Policy.class);
-        when(policy.ric()).thenReturn(ric);
-        when(policy.type()).thenReturn(policyType);
-        Policies policies = new Policies();
-        policies.put(policy);
-
-        StartupService serviceUnderTest = new StartupService(appConfigMock, refreshTaskMock, new Rics(),
-            new PolicyTypes(), a1ClientFactory, policies, new Services());
-
-        serviceUnderTest.startup();
-        serviceUnderTest.onRicConfigUpdate(getRicConfig(FIRST_RIC_NAME, FIRST_RIC_URL, MANAGED_NODE_A),
-            ApplicationConfig.RicConfigUpdate.ADDED);
-
-        assertEquals(RicState.UNDEFINED, ric.getState(), "Not correct state for " + FIRST_RIC_NAME);
+        assertEquals(0, rics.size(), "Ric not deleted");
     }
 
-    @SafeVarargs
-    private <T> Vector<T> toVector(T... objs) {
-        Vector<T> result = new Vector<>();
-        for (T o : objs) {
-            result.add(o);
+    private RicConfig getRicConfig(String name) {
+        return getRicConfig(name, null);
+    }
+
+    private RicConfig getRicConfig(String name, String managedElementName) {
+        List<String> managedElements = Collections.emptyList();
+        if (managedElementName != null) {
+            managedElements = Collections.singletonList(managedElementName);
         }
-        return result;
-    }
-
-    private RicConfig getRicConfig(String name, String baseUrl, String... managedElementIds) {
         ImmutableRicConfig ricConfig = ImmutableRicConfig.builder() //
             .name(name) //
-            .managedElementIds(toVector(managedElementIds)) //
-            .baseUrl(baseUrl) //
+            .managedElementIds(managedElements) //
+            .baseUrl("baseUrl") //
             .build();
         return ricConfig;
     }
