diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
index 74a43b9..d4a3640 100644
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
+++ b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/Common.java
@@ -57,10 +57,10 @@
         root.setLevel(Level.INFO);
 
         return options(
+                cleanCaches(),
                 ipojoBundles(),
                 junitBundles(),
                 testedBundle(),
-                eventadmin(),
                 systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("WARN")
         );
     }
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java
deleted file mode 100644
index 5a0b82e..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-
-public class TestDelayedOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("VoidOptionalCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("RefOptionalCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("BothOptionalCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("MapOptionalCheckServiceProvider").createComponentInstance(i6);
-            instance6.stop();
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dict");
-            instance7 = ipojoHelper.getFactory("DictOptionalCheckServiceProvider").createComponentInstance(i7);
-            instance7.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testSimple() {
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance1.stop();
-    }
-
-    @Test public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance2.stop();
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test public void testBoth() {
-        instance5.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance5.stop();
-    }
-
-    @Test public void testMap() {
-        instance6.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance6.stop();
-    }
-
-    @Test public void testDict() {
-        instance7.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance7.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 5ab7238..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestDelayedOptionalMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test
-    public void testSimple() {
-        instance1.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance1.stop();
-    }
-
-    @Test
-    public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 2);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance2.stop();
-    }
-
-    @Test
-    public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance3.stop();
-    }
-
-    @Test
-    public void testRef() {
-        instance4.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance4.stop();
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java
deleted file mode 100644
index 2ef9fe8..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("MRefOptionalCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("MBothOptionalCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("MMapOptionalCheckServiceProvider").createComponentInstance(i6);
-            instance6.stop();
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dict");
-            instance7 = ipojoHelper.getFactory("MDictOptionalCheckServiceProvider").createComponentInstance(i7);
-            instance7.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test public void testBoth() {
-        instance5.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance5.stop();
-    }
-
-    @Test public void testMap() {
-        instance6.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance6.stop();
-    }
-
-    @Test public void testDict() {
-        instance7.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance7.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index bf68b66..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalMultipleDependencies extends Common {
-
-    ComponentInstance instance3, instance4;
-    ComponentInstance fooProvider1, fooProvider2;
-
-
-    @Before
-    public void setUp() {
-        try {
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance3 = null;
-        instance4 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", (Boolean) props.get("result")); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance4.stop();
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java
deleted file mode 100644
index 4a7e733..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalDependencies.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5, instance6, instance7;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("MObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("MRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("MBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("MMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dictionary");
-            instance7 = ipojoHelper.getFactory("MDictOptionalCheckServiceProvider").createComponentInstance(i7);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testObject() {
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testMap() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testDict() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java
deleted file mode 100644
index 61571e4..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestMethodOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalMultipleDependencies extends Common {
-
-    ComponentInstance instance3, instance4;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider1.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("MObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("MRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance3 = null;
-        instance4 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(),  2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(),  2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java
deleted file mode 100644
index 7da97bc..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalDependencies.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalDependencies extends Common {
-	
-	ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-	ComponentInstance fooProvider;
-	
-	@Before public void setUp() {
-		try {
-			Properties prov = new Properties();
-			prov.put("instance.name","FooProvider");
-			fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-			fooProvider.stop();
-			
-			Properties i1 = new Properties();
-			i1.put("instance.name","Simple");
-			instance1 = ipojoHelper.getFactory("SimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-		
-			Properties i2 = new Properties();
-			i2.put("instance.name","Void");
-			instance2 = ipojoHelper.getFactory("VoidOptionalCheckServiceProvider").createComponentInstance(i2);
-		
-			Properties i3 = new Properties();
-			i3.put("instance.name","Object");
-			instance3 = ipojoHelper.getFactory("ObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-		
-			Properties i4 = new Properties();
-			i4.put("instance.name","Ref");
-			instance4 = ipojoHelper.getFactory("RefOptionalCheckServiceProvider").createComponentInstance(i4);
-			
-			Properties i5 = new Properties();
-            i5.put("instance.name","Both");
-            instance5 = ipojoHelper.getFactory("BothOptionalCheckServiceProvider").createComponentInstance(i5);
-            
-            Properties i6 = new Properties();
-            i6.put("instance.name","Map");
-            instance6 = ipojoHelper.getFactory("MapOptionalCheckServiceProvider").createComponentInstance(i6);
-            
-            Properties i7 = new Properties();
-            i7.put("instance.name","Dictionary");
-            instance7 = ipojoHelper.getFactory("DictOptionalCheckServiceProvider").createComponentInstance(i7);
-		} catch(Exception e) { fail(e.getMessage()); }		
-	}
-	
-	@After
-    public void tearDown() {
-		instance1.dispose();
-		instance2.dispose();
-		instance3.dispose();
-		instance4.dispose();
-		instance5.dispose();
-		instance6.dispose();
-		instance7.dispose();
-		fooProvider.dispose();
-		instance1 = null;
-		instance2 = null;
-		instance3 = null;
-		instance4 = null;
-		instance5 = null;
-		instance6 = null;
-		instance7 = null;
-		fooProvider = null;
-	}
-	
-	@Test public void testSimple() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		
-		//Check properties
-		assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertNull("Check FS invocation (object) - 1 ("+props.get("object")+")", props.get("object"));
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
-		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-		
-		fooProvider.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		assertNotNull("Check CheckService availability", cs_ref);
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		
-		//Check properties
-		assertTrue("check CheckService invocation - 2", ((Boolean)props.get("result")).booleanValue()); // True, a provider is there
-		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
-		assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
-		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-		
-		fooProvider.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);		
-	}
-	
-	@Test public void testVoid() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertNull("Check FS invocation (object) - 1", props.get("object"));
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 0);
-		assertEquals("Check FS invocation (double) - 1", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-		
-		fooProvider.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		assertNotNull("Check CheckService availability", cs_ref);
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-		assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 1);
-		assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-		assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 1);
-		assertEquals("Check FS invocation (double) - 2", ((Double)props.get("double")).doubleValue(), 1.0, 0);
-		
-		fooProvider.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
-		assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 1);
-		assertEquals("check void unbind callback invocation -3 ("+((Integer)props.get("voidU")) + ")", ((Integer)props.get("voidU")).intValue(), 1);
-		assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-		assertNull("Check FS invocation (object) - 3", props.get("object"));
-		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 0);
-		assertEquals("Check FS invocation (double) - 3", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-		
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);	
-	}
-	
-	@Test public void testObject() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-		assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-		
-		fooProvider.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		assertNotNull("Check CheckService availability", cs_ref);
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-		assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -2 (" + ((Integer)props.get("objectB")).intValue() + ")", ((Integer)props.get("objectB")).intValue(), 1);
-		assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-		
-		fooProvider.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue()); // Nullable object.
-		assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 1);
-		assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 1);
-		assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-		
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);		
-	}
-	
-	@Test public void testRef() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-		assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-		
-		fooProvider.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		assertNotNull("Check CheckService availability", cs_ref);
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-		assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 1);
-		assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-		
-		fooProvider.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
-		assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 1);
-		assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 1);
-		
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);
-	}
-	
-	@Test public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-        
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-        
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 1);
-  
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-	
-	@Test public void testMap() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-        
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-        
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 0);
-  
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-	
-	   @Test public void testDict() {
-	        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-	        assertNotNull("Check architecture availability", arch_ref);
-	        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-	        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-	        
-	        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-	        assertNotNull("Check CheckService availability", cs_ref);
-	        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-	        Properties props = cs.getProps();
-	        //Check properties
-	        assertFalse("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue()); // False is returned (nullable)
-	        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-	        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-	        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-	        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-	        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-	        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-	        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
-	        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
-	        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
-	        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-	        
-	        fooProvider.start();
-	        
-	        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-	        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-	        
-	        assertNotNull("Check CheckService availability", cs_ref);
-	        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-	        props = cs.getProps();
-	        //Check properties
-	        assertTrue("check CheckService invocation -2", ((Boolean)props.get("result")).booleanValue());
-	        assertEquals("check void bind invocation -2", ((Integer)props.get("voidB")).intValue(), 0);
-	        assertEquals("check void unbind callback invocation -2", ((Integer)props.get("voidU")).intValue(), 0);
-	        assertEquals("check object bind callback invocation -2", ((Integer)props.get("objectB")).intValue(), 0);
-	        assertEquals("check object unbind callback invocation -2", ((Integer)props.get("objectU")).intValue(), 0);
-	        assertEquals("check ref bind callback invocation -2", ((Integer)props.get("refB")).intValue(), 0);
-	        assertEquals("check ref unbind callback invocation -2", ((Integer)props.get("refU")).intValue(), 0);
-	        assertEquals("check both bind callback invocation -2", ((Integer)props.get("bothB")).intValue(), 0);
-	        assertEquals("check both unbind callback invocation -2", ((Integer)props.get("bothU")).intValue(), 0);
-	        assertEquals("check map bind callback invocation -2", ((Integer)props.get("mapB")).intValue(), 0);
-	        assertEquals("check map unbind callback invocation -2", ((Integer)props.get("mapU")).intValue(), 0);
-	        assertEquals("check dict bind callback invocation -2", ((Integer)props.get("dictB")).intValue(), 1);
-	        assertEquals("check dict unbind callback invocation -2", ((Integer)props.get("dictU")).intValue(), 0);
-	        
-	        fooProvider.stop();
-	        
-	        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-	        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-	        
-	        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-	        props = cs.getProps();
-	        //Check properties
-	        assertFalse("check CheckService invocation -3", ((Boolean)props.get("result")).booleanValue());
-	        assertEquals("check void bind invocation -3", ((Integer)props.get("voidB")).intValue(), 0);
-	        assertEquals("check void unbind callback invocation -3", ((Integer)props.get("voidU")).intValue(), 0);
-	        assertEquals("check object bind callback invocation -3", ((Integer)props.get("objectB")).intValue(), 0);
-	        assertEquals("check object unbind callback invocation -3", ((Integer)props.get("objectU")).intValue(), 0);
-	        assertEquals("check ref bind callback invocation -3", ((Integer)props.get("refB")).intValue(), 0);
-	        assertEquals("check ref unbind callback invocation -3", ((Integer)props.get("refU")).intValue(), 0);
-	        assertEquals("check both bind callback invocation -3", ((Integer)props.get("bothB")).intValue(), 0);
-	        assertEquals("check both unbind callback invocation -3", ((Integer)props.get("bothU")).intValue(), 0);
-	        assertEquals("check map bind callback invocation -3", ((Integer)props.get("mapB")).intValue(), 0);
-	        assertEquals("check map unbind callback invocation -3", ((Integer)props.get("mapU")).intValue(), 0);
-	        assertEquals("check dict bind callback invocation -3", ((Integer)props.get("dictB")).intValue(), 1);
-	        assertEquals("check dict unbind callback invocation -3", ((Integer)props.get("dictU")).intValue(), 1);
-	  
-	        id = null;
-	        cs = null;
-	        getContext().ungetService(arch_ref);
-	        getContext().ungetService(cs_ref);
-	    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java
deleted file mode 100644
index 8c97078..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalMultipleDependencies extends Common {
-
-	ComponentInstance instance1, instance2, instance3, instance4;
-	ComponentInstance fooProvider1, fooProvider2;
-	
-	@Before public void setUp() {
-		try {
-			Properties prov = new Properties();
-			prov.put("instance.name","FooProvider1");
-			fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-			fooProvider1.stop();
-		
-			Properties prov2 = new Properties();
-			prov2.put("instance.name","FooProvider2");
-			fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-			fooProvider2.stop();
-		
-			Properties i1 = new Properties();
-			i1.put("instance.name","Simple");
-			instance1 = ipojoHelper.getFactory("SimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
-		
-			Properties i2 = new Properties();
-			i2.put("instance.name","Void");
-			instance2 = ipojoHelper.getFactory("VoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
-		
-			Properties i3 = new Properties();
-			i3.put("instance.name","Object");
-			instance3 = ipojoHelper.getFactory("ObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-		
-			Properties i4 = new Properties();
-			i4.put("instance.name","Ref");
-			instance4 = ipojoHelper.getFactory("RefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-		} catch(Exception e) { fail(e.getMessage()); }
-		
-	}
-	
-	@After
-    public void tearDown() {
-		instance1.dispose();
-		instance2.dispose();
-		instance3.dispose();
-		instance4.dispose();
-		fooProvider1.dispose();
-		fooProvider2.dispose();
-		instance1 = null;
-		instance2 = null;
-		instance3 = null;
-		instance4 = null;
-		fooProvider1 = null;
-		fooProvider2 = null;
-	}
-	
-	@Test public void testSimple() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean)props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-		assertEquals("Check FS invocation (double) - 0", ((Double)props.get("double")).doubleValue(), 0.0, 0);
-		
-		fooProvider1.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 1", ((Boolean)props.get("result")).booleanValue()); // True, a provider is here
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-		
-		fooProvider2.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
-		fooProvider1.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-		assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
-
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);		
-	}
-	
-	@Test public void testVoid() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
-		fooProvider1.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 1);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 2);
-		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
-		fooProvider1.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 2);
-		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 1);
-		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 4", ((Integer)props.get("voidB")).intValue(), 2);
-		assertEquals("check void unbind callback invocation - 4", ((Integer)props.get("voidU")).intValue(), 2);
-		assertEquals("check object bind callback invocation - 4", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 4", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 4", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 4", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 4", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 4", ((Long)props.get("long")).longValue(), 0);
-
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);	
-	}
-	
-	@Test public void testObject() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
-		fooProvider1.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 1);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 2);
-		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
-		fooProvider1.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 2);
-		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 1);
-		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 2);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 2);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);		
-	}
-	
-	@Test public void testRef() {
-		ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-		assertNotNull("Check architecture availability", arch_ref);
-		InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-		
-		ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-		assertNotNull("Check CheckService availability", cs_ref);
-		CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		Properties props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 0);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
-		fooProvider1.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-		assertEquals("check void bind invocation - 1", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 1", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 1", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 1", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 1", ((Integer)props.get("refB")).intValue(), 1);
-		assertEquals("check ref unbind callback invocation - 1", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 1", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 1", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.start();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 2", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 2", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 2", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 2", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 2", ((Integer)props.get("refB")).intValue(), 2);
-		assertEquals("check ref unbind callback invocation - 2", ((Integer)props.get("refU")).intValue(), 0);
-		assertEquals("Check FS invocation (int) - 2", ((Integer)props.get("int")).intValue(), 2);
-		assertEquals("Check FS invocation (long) - 2", ((Long)props.get("long")).longValue(), 2);
-
-		fooProvider1.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-		assertEquals("check void bind invocation - 3", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 3", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 3", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 3", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 3", ((Integer)props.get("refB")).intValue(), 2);
-		assertEquals("check ref unbind callback invocation - 3", ((Integer)props.get("refU")).intValue(), 1);
-		assertEquals("Check FS invocation (int) - 3", ((Integer)props.get("int")).intValue(), 1);
-		assertEquals("Check FS invocation (long) - 3", ((Long)props.get("long")).longValue(), 1);
-
-		fooProvider2.stop();
-		
-		id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-		assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-		
-		cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-		props = cs.getProps();
-		//Check properties
-		assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-		assertEquals("check void bind invocation - 0", ((Integer)props.get("voidB")).intValue(), 0);
-		assertEquals("check void unbind callback invocation - 0", ((Integer)props.get("voidU")).intValue(), 0);
-		assertEquals("check object bind callback invocation - 0", ((Integer)props.get("objectB")).intValue(), 0);
-		assertEquals("check object unbind callback invocation - 0", ((Integer)props.get("objectU")).intValue(), 0);
-		assertEquals("check ref bind callback invocation - 0", ((Integer)props.get("refB")).intValue(), 2);
-		assertEquals("check ref unbind callback invocation - 0", ((Integer)props.get("refU")).intValue(), 2);
-		assertEquals("Check FS invocation (int) - 0", ((Integer)props.get("int")).intValue(), 0);
-		assertEquals("Check FS invocation (long) - 0", ((Long)props.get("long")).longValue(), 0);
-
-		id = null;
-		cs = null;
-		getContext().ungetService(arch_ref);
-		getContext().ungetService(cs_ref);
-	}
-
-	
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java
deleted file mode 100644
index c851c9b..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestOptionalNoNullableDependencies.java
+++ /dev/null
@@ -1,549 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalNoNullableDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("SimpleOptionalNoNullableCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("VoidOptionalNoNullableCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ObjectOptionalNoNullableCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("RefOptionalNoNullableCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("BothOptionalNoNullableCheckServiceProvider").createComponentInstance(i5);
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("MapOptionalNoNullableCheckServiceProvider").createComponentInstance(i6);
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dictionary");
-            instance7 = ipojoHelper.getFactory("DictOptionalNoNullableCheckServiceProvider").createComponentInstance(i7);
-        } catch (Exception e) {
-            e.getMessage();
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        // no service, no nullable => runtime exception expected
-        assertTrue("check excepted exception", ((Boolean) props.get("exception")).booleanValue());
-        assertNull("check CheckService invocation - 1 (" + props.get("result") + ")", props.get("result")); // Null
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1 (" + props.get("object") + ")", props.get("object"));
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is there
-        // No exception expected
-        assertFalse("check unexcepted exception", ((Boolean) props.get("exception")).booleanValue());
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation - 1", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result"));
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 3", props.get("object"));
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2 (" + ((Integer) props.get("objectB")).intValue() + ")", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result")); // No provider.
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -1", props.get("result")); //Null, no provider
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testDict() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testMap() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -1", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertNull("check CheckService invocation -3", props.get("result")); // Null, no provider
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java
deleted file mode 100644
index 016e958..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedCollectionMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedCollectionMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider1.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleCollectionCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Optional");
-            instance2 = ipojoHelper.getFactory("ProxiedOptionalCollectionCheckServiceProvider").createComponentInstance(i2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testOptional() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java
deleted file mode 100644
index 2613efa..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedMultipleDependencies.java
+++ /dev/null
@@ -1,524 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidMultipleCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefMultipleCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("ProxiedBothMultipleCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("ProxiedMapMultipleCheckServiceProvider").createComponentInstance(i6);
-            instance6.stop();
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dict");
-            instance7 = ipojoHelper.getFactory("ProxiedDictMultipleCheckServiceProvider").createComponentInstance(i7);
-            instance7.stop();
-
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testSimple() {
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance1.stop();
-    }
-
-    @Test public void testVoid() {
-        instance2.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance2.stop();
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        instance4.stop();
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testBoth() {
-        instance5.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 2);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 3", ((Integer) props.get("bothB")).intValue(), 2);
-        assertEquals("check both unbind callback invocation - 3", ((Integer) props.get("bothU")).intValue(), 1);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        instance5.stop();
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testMap() {
-        instance6.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 2);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 2);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        instance6.stop();
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testDict() {
-        instance7.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 2);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 2);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        instance7.stop();
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java
deleted file mode 100644
index d715aee..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,497 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-
-public class TestProxiedDelayedOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
-            instance6.stop();
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dict");
-            instance7 = ipojoHelper.getFactory("ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
-            instance7.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testSimple() {
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance1.stop();
-    }
-
-    @Test public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance2.stop();
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test public void testBoth() {
-        instance5.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance5.stop();
-    }
-
-    @Test public void testMap() {
-        instance6.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance6.stop();
-    }
-
-    @Test public void testDict() {
-        instance7.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 1", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation - 2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation - 2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation - 2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation - 2", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance7.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java
deleted file mode 100644
index 94d1802..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedOptionalMultipleDependencies.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedOptionalMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalMultipleCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalMultipleCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalMultipleCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefOptionalMultipleCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testSimple() {
-        instance1.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance1.stop();
-    }
-
-    @Test public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 2);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 2);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance2.stop();
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 2);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 2);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 2);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 2);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance4.stop();
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java
deleted file mode 100644
index 9698300..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedDelayedSimpleDependencies.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedDelayedSimpleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-    ComponentInstance fooProvider;
-
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("ProxiedBothCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("ProxiedMapCheckServiceProvider").createComponentInstance(i6);
-            instance6.stop();
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dict");
-            instance7 = ipojoHelper.getFactory("ProxiedDictCheckServiceProvider").createComponentInstance(i7);
-            instance7.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testSimple() {
-        instance1.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-        fooProvider.stop();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        fooProvider.start();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-        fooProvider.stop();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        instance1.stop();
-    }
-
-    @Test public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance2.stop();
-    }
-
-    @Test public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test public void testRef() {
-        instance4.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test public void testBoth() {
-        instance5.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance5.stop();
-    }
-
-    @Test public void testMap() {
-        instance6.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance6.stop();
-    }
-
-    @Test public void testDict() {
-        instance7.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance7.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java
deleted file mode 100644
index 7707f57..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedListMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedListMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider1.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleListCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Optional");
-            instance2 = ipojoHelper.getFactory("ProxiedOptionalListCheckServiceProvider").createComponentInstance(i2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testOptional() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java
deleted file mode 100644
index c4603a4..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedOptionalDependencies.java
+++ /dev/null
@@ -1,553 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("ProxiedBothOptionalCheckServiceProvider").createComponentInstance(i5);
-
-            Properties i6 = new Properties();
-            i6.put("instance.name", "Map");
-            instance6 = ipojoHelper.getFactory("ProxiedMapOptionalCheckServiceProvider").createComponentInstance(i6);
-
-            Properties i7 = new Properties();
-            i7.put("instance.name", "Dictionary");
-            instance7 = ipojoHelper.getFactory("ProxiedDictOptionalCheckServiceProvider").createComponentInstance(i7);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        fooProvider = null;
-    }
-
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1 (" + props.get("object") + ")", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is there
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 3", props.get("object"));
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2 (" + ((Integer) props.get("objectB")).intValue() + ")", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue()); // Nullable object.
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testMap() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 1);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testDict() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -1", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer) props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -2", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -2", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -2", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -2", ((Integer) props.get("dictU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -3", ((Integer) props.get("mapB")).intValue(), 0);
-        assertEquals("check map unbind callback invocation -3", ((Integer) props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -3", ((Integer) props.get("dictB")).intValue(), 1);
-        assertEquals("check dict unbind callback invocation -3", ((Integer) props.get("dictU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java
deleted file mode 100644
index cb8ec2c..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSetMultipleDependencies.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedSetMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider1.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleSetCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Optional");
-            instance2 = ipojoHelper.getFactory("ProxiedOptionalSetCheckServiceProvider").createComponentInstance(i2);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test public void testOptional() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 0", ((Boolean) props.get("result")).booleanValue()); // False : no provider
-        assertEquals("check void bind invocation - 0", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 0", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 0", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 0", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 0", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 0", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 0", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 0", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 0", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        fooProvider1.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.start();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 2);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 2);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 2.0, 0);
-
-        fooProvider1.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 4", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 3", ((Boolean) props.get("result")).booleanValue()); // True, it still one provider.
-        assertEquals("check void bind invocation - 3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider2.stop();
-
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 4", ((Boolean) props.get("result")).booleanValue()); // False, no more provider.
-        assertEquals("check void bind invocation - 4", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 4", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 4", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 4", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 4", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 4", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 4", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 4", ((Long) props.get("long")).longValue(), 0);
-        assertEquals("Check FS invocation (double) - 4", ((Double) props.get("double")).doubleValue(), 0.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java
deleted file mode 100644
index 0d5b71f..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxiedSimpleDependencies.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxiedSimpleDependencies extends Common {
-    
-    ComponentInstance instance1, instance2, instance3, instance4, instance5, instance6, instance7, instance8;
-    ComponentInstance fooProvider;
-    
-    @Before public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name","FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-        
-            Properties i1 = new Properties();
-            i1.put("instance.name","Simple");
-            instance1 = ipojoHelper.getFactory("ProxiedSimpleCheckServiceProvider").createComponentInstance(i1);
-        
-            Properties i2 = new Properties();
-            i2.put("instance.name","Void");
-            instance2 = ipojoHelper.getFactory("ProxiedVoidCheckServiceProvider").createComponentInstance(i2);
-        
-            Properties i3 = new Properties();
-            i3.put("instance.name","Object");
-            instance3 = ipojoHelper.getFactory("ProxiedObjectCheckServiceProvider").createComponentInstance(i3);
-        
-            Properties i4 = new Properties();
-            i4.put("instance.name","Ref");
-            instance4 = ipojoHelper.getFactory("ProxiedRefCheckServiceProvider").createComponentInstance(i4);
-            
-            Properties i5 = new Properties();
-            i5.put("instance.name","Both");
-            instance5 = ipojoHelper.getFactory("ProxiedBothCheckServiceProvider").createComponentInstance(i5);
-            
-            Properties i6 = new Properties();
-            i6.put("instance.name","Double");
-            instance6 = ipojoHelper.getFactory("ProxiedDoubleCheckServiceProvider").createComponentInstance(i6);
-            
-            Properties i7 = new Properties();
-            i7.put("instance.name","Map");
-            instance7 = ipojoHelper.getFactory("ProxiedMapCheckServiceProvider").createComponentInstance(i7);
-            
-            Properties i8 = new Properties();
-            i8.put("instance.name","Dictionary");
-            instance8 = ipojoHelper.getFactory("ProxiedDictCheckServiceProvider").createComponentInstance(i8);
-        } catch(Exception e) { 
-            e.printStackTrace();
-            fail(e.getMessage()); }
-        
-    }
-    
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        instance6.dispose();
-        instance7.dispose();
-        instance8.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        instance6 = null;
-        instance7 = null;
-        instance8 = null;
-        fooProvider = null;
-    }
-    
-    @Test public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-        
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);		
-    }
-    
-    @Test public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        Object o = osgiHelper.getServiceObject(cs_ref);
-        CheckService cs = (CheckService) o;
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1 ("+((Integer)props.get("voidB")).intValue()+")", ((Integer)props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);		
-    }
-    
-    @Test public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);		
-    }
-    
-    @Test public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-    
-    @Test public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-    
-    @Test public void testDouble() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance6.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        assertNotNull("Check cs", cs);
-        cs.check();
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);       
-    }
-    
-    @Test public void testMap() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-        
-        fooProvider.start();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-        
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance7.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-        assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 1);
-        assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
-        assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 0);
-        assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-        
-        fooProvider.stop();
-        
-        id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-        
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-    
-       @Test public void testDict() {
-            ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance8.getInstanceName());
-            assertNotNull("Check architecture availability", arch_ref);
-            InstanceDescription id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-            assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-            
-            fooProvider.start();
-            
-            id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-            assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-            
-            ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance8.getInstanceName());
-            assertNotNull("Check CheckService availability", cs_ref);
-            CheckService cs = (CheckService) osgiHelper.getServiceObject(cs_ref);
-            Properties props = cs.getProps();
-            //Check properties
-            assertTrue("check CheckService invocation -1", ((Boolean)props.get("result")).booleanValue());
-            assertEquals("check void bind invocation -1", ((Integer)props.get("voidB")).intValue(), 0);
-            assertEquals("check void unbind callback invocation -1", ((Integer)props.get("voidU")).intValue(), 0);
-            assertEquals("check object bind callback invocation -1", ((Integer)props.get("objectB")).intValue(), 0);
-            assertEquals("check object unbind callback invocation -1", ((Integer)props.get("objectU")).intValue(), 0);
-            assertEquals("check ref bind callback invocation -1", ((Integer)props.get("refB")).intValue(), 0);
-            assertEquals("check ref unbind callback invocation -1", ((Integer)props.get("refU")).intValue(), 0);
-            assertEquals("check both bind callback invocation -1", ((Integer)props.get("bothB")).intValue(), 0);
-            assertEquals("check both unbind callback invocation -1", ((Integer)props.get("bothU")).intValue(), 0);
-            assertEquals("check map bind callback invocation -1", ((Integer)props.get("mapB")).intValue(), 0);
-            assertEquals("check map unbind callback invocation -1", ((Integer)props.get("mapU")).intValue(), 0);
-            assertEquals("check dict bind callback invocation -1", ((Integer)props.get("dictB")).intValue(), 1);
-            assertEquals("check dict unbind callback invocation -1", ((Integer)props.get("dictU")).intValue(), 0);
-            
-            fooProvider.stop();
-            
-            id = ((Architecture) osgiHelper.getServiceObject(arch_ref)).getInstanceDescription();
-            assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-            
-            id = null;
-            cs = null;
-            getContext().ungetService(arch_ref);
-            getContext().ungetService(cs_ref);
-        }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java
deleted file mode 100644
index 15c3d2f..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/TestProxyTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.handlers.dependency.DependencyHandler;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.apache.felix.ipojo.runtime.core.test.services.FooService;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestProxyTest extends Common {
-
-
-    @Test
-    public void testDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties prov = new Properties();
-        prov.put("instance.name", "FooProvider1-Proxy");
-        ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-        assertTrue(cs.check());
-
-        fooProvider1.dispose();
-        instance1.dispose();
-    }
-
-    @Test
-    public void testDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties i1 = new Properties();
-        i1.put("instance.name", "DelegatorNullable");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-        assertFalse(cs.check()); // Nullable.
-
-        instance1.dispose();
-    }
-
-
-    @Test
-    public void testGetAndDelegation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties prov = new Properties();
-        prov.put("instance.name", "FooProvider1-Proxy");
-        ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-
-        assertTrue(cs.check());
-
-        fooProvider1.dispose();
-        instance1.dispose();
-    }
-
-    @Test
-    public void testGetAndDelegationOnNullable() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties i1 = new Properties();
-        i1.put("instance.name", "DelegatorNullable");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceGetAndDelegate").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-        assertFalse(cs.check()); // Nullable.
-
-
-        instance1.dispose();
-    }
-
-    @Test
-    public void testImmediate() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties prov = new Properties();
-        prov.put("instance.name", "FooProvider1-Proxy");
-        ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
-        ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(), "(service.pid=Helper)");
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertTrue(helper.toString().contains("$$Proxy")); // This is the suffix.
-
-        assertTrue(cs.check());
-
-        fooProvider1.dispose();
-        instance1.dispose();
-    }
-
-    @Test
-    public void testImmediateNoService() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator-with-no-service");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceNoDelegate").createComponentInstance(i1);
-
-        ServiceReference ref = osgiHelper.getServiceReference(CheckService.class.getName(), "(service.pid=Helper)");
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        try {
-            cs.getProps();
-            fail("Exception expected");
-        } catch (RuntimeException e) {
-            //OK
-        }
-
-        instance1.dispose();
-    }
-
-    @Test
-    public void testProxyDisabled() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        // Disable proxy
-        System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_DISABLED);
-        Properties prov = new Properties();
-        prov.put("instance.name", "FooProvider1-Proxy");
-        ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertFalse(helper.toString().contains("$$Proxy")); // Not a proxy.
-
-        assertTrue(cs.check());
-
-        fooProvider1.dispose();
-        instance1.dispose();
-        System.setProperty(DependencyHandler.PROXY_SETTINGS_PROPERTY, DependencyHandler.PROXY_ENABLED);
-
-    }
-
-    @Test
-    public void testDynamicProxy() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        // Dynamic proxy
-        System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.DYNAMIC_PROXY);
-        Properties prov = new Properties();
-        prov.put("instance.name", "FooProvider1-Proxy");
-        ComponentInstance fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-
-        Properties i1 = new Properties();
-        i1.put("instance.name", "Delegator");
-        ComponentInstance instance1 = ipojoHelper.getFactory(
-                "org.apache.felix.ipojo.runtime.core.test.components.proxy.CheckServiceDelegator").createComponentInstance(i1);
-
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull(ref);
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-
-        Properties props = cs.getProps();
-        FooService helper = (FooService) props.get("helper.fs");
-        assertNotNull(helper);
-        assertFalse(helper.toString().contains("$$Proxy")); // Dynamic proxy.
-        assertTrue(helper.toString().contains("DynamicProxyFactory"));
-        assertTrue(helper.hashCode() > 0);
-
-        assertTrue(helper.equals(helper));
-        assertFalse(helper.equals(i1)); // This is a quite stupid test...
-
-        assertTrue(cs.check());
-
-        fooProvider1.dispose();
-        instance1.dispose();
-        System.setProperty(DependencyHandler.PROXY_TYPE_PROPERTY, DependencyHandler.SMART_PROXY);
-
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java
deleted file mode 100644
index e6611e9..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/comparator/TestComparator.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies.comparator;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
-public class TestComparator extends Common {
-
-    String gradeFactory = "COMPARATOR-gradedFooProvider";
-    String dynamic = "COMPARATOR-DynamicCheckService";
-    String dynamicpriority = "COMPARATOR-DynamicPriorityCheckService";
-
-
-    ComponentInstance dynInstance;
-    ComponentInstance dpInstance;
-
-    @Before
-    public void setUp() {
-        dynInstance = ipojoHelper.createComponentInstance(dynamic, (Properties) null);
-        dpInstance = ipojoHelper.createComponentInstance(dynamicpriority, (Properties) null);
-    }
-
-    @After
-    public void tearDown() {
-        ipojoHelper.dispose();
-    }
-
-    @Test
-    public void testDynamic() {
-        createGrade(1);
-        ComponentInstance grade2 = createGrade(2);
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), dynInstance.getInstanceName());
-        assertNotNull("CS availability", ref);
-
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-        Properties result = cs.getProps();
-        int fsGrade = ((Integer) result.get("fs")).intValue();
-        int fs2Grade = ((Integer) result.get("fs2")).intValue();
-        int[] fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -1", 2, fsGrade);
-        assertEquals("fs2 grade -1", 2, fs2Grade);
-        assertEquals("fss grade size -1", 2, fssGrades.length);
-
-
-        assertEquals("fss grade[0] -1", 2, fssGrades[0]);
-        assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
-        createGrade(3);
-        result = cs.getProps();
-        fsGrade = ((Integer) result.get("fs")).intValue();
-        fs2Grade = ((Integer) result.get("fs2")).intValue();
-        fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -2", 2, fsGrade);
-        assertEquals("fs2 grade -2", 2, fs2Grade);
-        assertEquals("fss grade size -2", 3, fssGrades.length);
-        assertEquals("fss grade[0] -2", 2, fssGrades[0]);
-        assertEquals("fss grade[1] -2", 1, fssGrades[1]);
-        assertEquals("fss grade[2] -2", 3, fssGrades[2]);
-
-        grade2.stop();
-
-        result = cs.getProps();
-        fsGrade = ((Integer) result.get("fs")).intValue();
-        fs2Grade = ((Integer) result.get("fs2")).intValue();
-        fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -3", 3, fsGrade);
-        assertEquals("fs2 grade -3", 3, fs2Grade);
-        assertEquals("fss grade size -3", 2, fssGrades.length);
-        assertEquals("fss grade[0] -3", 1, fssGrades[0]);
-        assertEquals("fss grade[1] -3", 3, fssGrades[1]);
-    }
-
-    @Test
-    public void testDynamicPriority() {
-        createGrade(1);
-        ComponentInstance grade2 = createGrade(2);
-
-        ServiceReference ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), dpInstance.getInstanceName());
-        assertNotNull("CS availability", ref);
-
-        CheckService cs = (CheckService) osgiHelper.getServiceObject(ref);
-        Properties result = cs.getProps();
-        int fsGrade = ((Integer) result.get("fs")).intValue();
-        int fs2Grade = ((Integer) result.get("fs2")).intValue();
-        int[] fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -1", 2, fsGrade);
-        assertEquals("fs2 grade -1", 2, fs2Grade);
-        assertEquals("fss grade size -1", 2, fssGrades.length);
-        assertEquals("fss grade[0] -1", 2, fssGrades[0]);
-        assertEquals("fss grade[1] -1", 1, fssGrades[1]);
-
-        createGrade(3);
-        result = cs.getProps();
-        fsGrade = ((Integer) result.get("fs")).intValue();
-        fs2Grade = ((Integer) result.get("fs2")).intValue();
-        fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -2", 3, fsGrade);
-        assertEquals("fs2 grade -2", 3, fs2Grade);
-        assertEquals("fss grade size -2", 3, fssGrades.length);
-        assertEquals("fss grade[0] -2", 3, fssGrades[0]);
-        assertEquals("fss grade[1] -2", 2, fssGrades[1]);
-        assertEquals("fss grade[2] -2", 1, fssGrades[2]);
-
-        grade2.stop();
-
-        result = cs.getProps();
-        fsGrade = ((Integer) result.get("fs")).intValue();
-        fs2Grade = ((Integer) result.get("fs2")).intValue();
-        fssGrades = (int[]) result.get("fss");
-
-        assertEquals("fs grade -3", 3, fsGrade);
-        assertEquals("fs2 grade -3", 3, fs2Grade);
-        assertEquals("fss grade size -3", 2, fssGrades.length);
-        assertEquals("fss grade[0] -3", 3, fssGrades[0]);
-        assertEquals("fss grade[1] -3", 1, fssGrades[1]);
-    }
-
-    private ComponentInstance createGrade(int grade) {
-        Properties props = new Properties();
-        props.put("grade", new Integer(grade));
-        return ipojoHelper.createComponentInstance(gradeFactory, props);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java
deleted file mode 100644
index 93b6291..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestDelayedOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-            instance1.stop();
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-            instance2.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testSimple() {
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance1.stop();
-    }
-
-    @Test
-    public void testVoid() {
-        instance2.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 5);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 5);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 5.0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance2.stop();
-    }
-
-    @Test
-    public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test
-    public void testRef() {
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test
-    public void testBoth() {
-        instance5.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation - 2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation - 2", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java
deleted file mode 100644
index 1ced9e9..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodDelayedOptionalDependencies.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestMethodDelayedOptionalDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-            instance3.stop();
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-            instance4.stop();
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
-            instance5.stop();
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testObject() {
-        instance3.start();
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance3.stop();
-    }
-
-    @Test
-    public void testRef() {
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-    @Test
-    public void testBoth() {
-        instance5.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-
-        instance4.stop();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java
deleted file mode 100644
index 7aa8423..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestMethodOptionalDependencies.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestMethodOptionalDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("DIMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("DIMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("DIMBothOptionalCheckServiceProvider").createComponentInstance(i5);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testObject() {
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java
deleted file mode 100644
index f68b7b5..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/di/TestOptionalDependencies.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.di;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("DISimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("DIVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("DIObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("DIRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("DIBothOptionalCheckServiceProvider").createComponentInstance(i5);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 5);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 5);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, a provider is there
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 5);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 5);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0, 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 1);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 3", props.get("object"));
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 5);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 5);
-        assertEquals("Check FS invocation (double) - 3", ((Double) props.get("double")).doubleValue(), 5.0, 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2 (" + ((Integer) props.get("objectB")).intValue() + ")", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 1);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 1);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java
deleted file mode 100644
index bb1d1a0..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/optional/TestNullableTransitiveClassloading.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package org.apache.felix.ipojo.runtime.core.test.dependencies.optional;
-
-import org.apache.felix.ipojo.*;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.junit.Test;
-
-
-/**
- * Reproduces FELIX-2093
- * iPOJO doesn't always use the correct class loader to load nullable object.
- */
-public class TestNullableTransitiveClassloading extends Common {
-
-
-    @Test
-    public void testCreation() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        Factory factory = ipojoHelper.getFactory("optional-log-cons");
-        ComponentInstance ci = factory.createComponentInstance(null);
-        ci.dispose();
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java
deleted file mode 100644
index 3507c68..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestDynamicPriority.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.apache.felix.ipojo.runtime.core.test.services.FooService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestDynamicPriority extends Common {
-
-    ComponentInstance instance1, instance3;
-    ComponentInstance fooProvider;
-    ComponentInstance fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider-1");
-            prov.put("service.ranking", "1");
-            fooProvider = ipojoHelper.getFactory("RankedFooProviderType").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider-2");
-            prov2.put("service.ranking", "0");
-            fooProvider2 = ipojoHelper.getFactory("RankedFooProviderType").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("DPSimpleCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("DPObjectCheckServiceProvider").createComponentInstance(i3);
-
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance3.dispose();
-        fooProvider.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance3 = null;
-        fooProvider = null;
-        fooProvider2 = null;
-    }
-
-    @Test
-    public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-        fooProvider2.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        // Check grade
-        Integer grade = (Integer) cs.getProps().get("int");
-        assertEquals("Check first grade", 1, grade.intValue());
-
-        fooProvider.stop(); // Turn off the best provider.
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        // Check grade
-        grade = (Integer) cs.getProps().get("int");
-        assertEquals("Check second grade", 0, grade.intValue());
-
-        fooProvider.start(); // Turn on the best provider.
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        // Check grade
-        grade = (Integer) cs.getProps().get("int");
-        assertEquals("Check third grade", 1, grade.intValue());
-
-
-        // Increase the second provider grade.
-        ServiceReference fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider2.getInstanceName());
-        assertNotNull("Check foo service (2) reference", fs_ref);
-        FooService fs = (FooService) getContext().getService(fs_ref);
-
-        fs.foo(); // Increase the grade (now = 2)
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        // Check grade
-        grade = (Integer) cs.getProps().get("int");
-        assertEquals("Check fourth grade", 2, grade.intValue());
-
-        // Increase the other provider grade.
-        fs_ref = ipojoHelper.getServiceReferenceByName(FooService.class.getName(), fooProvider.getInstanceName());
-        assertNotNull("Check foo service (1) reference", fs_ref);
-        fs = (FooService) getContext().getService(fs_ref);
-        fs.foo(); //(grade = 3)
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        // Check grade
-        grade = (Integer) cs.getProps().get("int");
-        assertEquals("Check fifth grade", 3, grade.intValue());
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-        getContext().ungetService(fs_ref);
-        fooProvider.stop();
-        fooProvider2.stop();
-    }
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java
deleted file mode 100644
index 6dd432c..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodOptionalDependencies.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticMethodOptionalDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5;
-
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("StaticMObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("StaticMRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("StaticMBothOptionalCheckServiceProvider").createComponentInstance(i5);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testObject() {
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java
deleted file mode 100644
index 1ffc4a1..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMethodSimpleDependencies.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticMethodSimpleDependencies extends Common {
-
-    ComponentInstance instance3, instance4, instance5;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("StaticMObjectCheckServiceProvider").createComponentInstance(i3);
-            assertNotNull("check instance 3", instance3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("StaticMRefCheckServiceProvider").createComponentInstance(i4);
-            assertNotNull("check instance 4", instance4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("StaticMBothCheckServiceProvider").createComponentInstance(i5);
-            assertNotNull("check instance 5", instance5);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-
-    @Test
-    public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java
deleted file mode 100644
index a24591e..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticMultipleDependencies.java
+++ /dev/null
@@ -1,325 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-
-public class TestStaticMultipleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4;
-    ComponentInstance fooProvider1, fooProvider2;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider1");
-            fooProvider1 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider1.stop();
-
-            Properties prov2 = new Properties();
-            prov2.put("instance.name", "FooProvider2");
-            fooProvider2 = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov2);
-            fooProvider2.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("StaticSimpleMultipleCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("StaticVoidMultipleCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("StaticObjectMultipleCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("StaticRefMultipleCheckServiceProvider").createComponentInstance(i4);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        fooProvider1.dispose();
-        fooProvider2.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        fooProvider1 = null;
-        fooProvider2 = null;
-    }
-
-    @Test
-    public void testSimple() {
-        instance1.stop();
-        fooProvider1.start();
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider2.start();
-        ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider1.stop();
-        // instance is stopped and then restarted, so bound to fooprovider 2.
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testVoid() {
-        instance2.stop();
-        fooProvider1.start();
-        instance2.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider2.start();
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider1.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testObject() {
-        instance3.stop();
-        fooProvider1.start();
-        instance3.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        // Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider2.start();
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        // Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider1.stop();
-        // Instance stopped and then restarted, bound to foo provider 2.
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testRef() {
-        instance4.stop();
-        fooProvider1.start();
-        instance4.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // True, a provider is here
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 1", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider2.start();
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, two providers are here
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-        assertEquals("Check FS invocation (double) - 2", ((Double) props.get("double")).doubleValue(), 1.0);
-
-        fooProvider1.stop();
-        // Stop and then restarted, bound to foo provider 2.
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 5", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java
deleted file mode 100644
index 1ba004d..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticOptionalDependencies.java
+++ /dev/null
@@ -1,521 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.MissingHandlerException;
-import org.apache.felix.ipojo.UnacceptableConfiguration;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticOptionalDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("StaticSimpleOptionalCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("StaticVoidOptionalCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("StaticObjectOptionalCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("StaticRefOptionalCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("StaticBothOptionalCheckServiceProvider").createComponentInstance(i5);
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-
-        //Check properties
-        assertFalse("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // False, the provider was not bound
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testDelayedSimple() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        instance1.stop();
-        fooProvider.start();
-        instance1.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
-        fooProvider.stop();
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken,re started with no service.
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation - 1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation - 1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 1", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 1", props.get("object"));
-        assertEquals("Check FS invocation (int) - 1", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 1", ((Long) props.get("long")).longValue(), 0);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3 (" + ((Integer) props.get("voidU")) + ")", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertNull("Check FS invocation (object) - 3", props.get("object"));
-        assertEquals("Check FS invocation (int) - 3", ((Integer) props.get("int")).intValue(), 0);
-        assertEquals("Check FS invocation (long) - 3", ((Long) props.get("long")).longValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testDelayedVoid() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        instance2.stop();
-        fooProvider.start();
-        instance2.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
-        fooProvider.stop();
-        // The instance is restarted.
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID); // Dependency broken and then (no service injected) restarted
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2 (" + ((Integer) props.get("objectB")).intValue() + ")", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    @Test
-    public void testDelayedObject() throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException {
-        instance3.stop();
-        fooProvider.start();
-        instance3.start();
-
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-
-        //Check properties
-        assertTrue("check CheckService invocation - 2", ((Boolean) props.get("result")).booleanValue()); // True, the provider was bound
-        assertEquals("check void bind invocation - 2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation - 2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation - 2", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation - 2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation - 2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation - 2", ((Integer) props.get("refU")).intValue(), 0);
-        assertNotNull("Check FS invocation (object) - 2", props.get("object"));
-        assertEquals("Check FS invocation (int) - 2", ((Integer) props.get("int")).intValue(), 1);
-        assertEquals("Check FS invocation (long) - 2", ((Long) props.get("long")).longValue(), 1);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID); // Dependency broken and restarted with no service
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    public void atestRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-    public void atestBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue()); // False is returned (nullable)
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -2", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -2", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -2", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -2", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -2", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -2", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -2", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -2", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -2", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 3 (" + id.getState() + ")", id.getState() == ComponentInstance.VALID);
-
-        cs = (CheckService) getContext().getService(cs_ref);
-        props = cs.getProps();
-        //Check properties
-        assertFalse("check CheckService invocation -3", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -3", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -3", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -3", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -3", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -3", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -3", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -3", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -3", ((Integer) props.get("bothU")).intValue(), 0);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-        getContext().ungetService(cs_ref);
-    }
-
-
-}
diff --git a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java b/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java
deleted file mode 100644
index 4ab7404..0000000
--- a/ipojo/runtime/core-it/src/it/ipojo-core-service-dependency-test/src/test/java/org/apache/felix/ipojo/runtime/core/test/dependencies/policies/TestStaticSimpleDependencies.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.runtime.core.test.dependencies.policies;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.architecture.InstanceDescription;
-import org.apache.felix.ipojo.runtime.core.test.dependencies.Common;
-import org.apache.felix.ipojo.runtime.core.test.services.CheckService;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.osgi.framework.ServiceReference;
-
-import java.util.Properties;
-
-import static org.junit.Assert.*;
-
-public class TestStaticSimpleDependencies extends Common {
-
-    ComponentInstance instance1, instance2, instance3, instance4, instance5;
-    ComponentInstance fooProvider;
-
-    @Before
-    public void setUp() {
-        try {
-            Properties prov = new Properties();
-            prov.put("instance.name", "FooProvider");
-            fooProvider = ipojoHelper.getFactory("FooProviderType-1").createComponentInstance(prov);
-            fooProvider.stop();
-
-            Properties i1 = new Properties();
-            i1.put("instance.name", "Simple");
-            instance1 = ipojoHelper.getFactory("StaticSimpleCheckServiceProvider").createComponentInstance(i1);
-
-            Properties i2 = new Properties();
-            i2.put("instance.name", "Void");
-            instance2 = ipojoHelper.getFactory("StaticVoidCheckServiceProvider").createComponentInstance(i2);
-
-            Properties i3 = new Properties();
-            i3.put("instance.name", "Object");
-            instance3 = ipojoHelper.getFactory("StaticObjectCheckServiceProvider").createComponentInstance(i3);
-
-            Properties i4 = new Properties();
-            i4.put("instance.name", "Ref");
-            instance4 = ipojoHelper.getFactory("StaticRefCheckServiceProvider").createComponentInstance(i4);
-
-            Properties i5 = new Properties();
-            i5.put("instance.name", "Both");
-            instance5 = ipojoHelper.getFactory("StaticBothCheckServiceProvider").createComponentInstance(i5);
-        } catch (Exception e) {
-            e.printStackTrace();
-            fail(e.getMessage());
-        }
-
-    }
-
-    @After
-    public void tearDown() {
-        instance1.dispose();
-        instance2.dispose();
-        instance3.dispose();
-        instance4.dispose();
-        instance5.dispose();
-        fooProvider.dispose();
-        instance1 = null;
-        instance2 = null;
-        instance3 = null;
-        instance4 = null;
-        instance5 = null;
-        fooProvider = null;
-    }
-
-    @Test
-    public void testSimple() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 1", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-
-        fooProvider.stop();
-        // instance1 has to be stopped and restarted.
-
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was invalidated and revalidated.
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance1.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        cs = (CheckService) getContext().getService(cs_ref);
-        assertTrue("check CheckService invocation", cs.check());
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance1.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 3", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-    }
-
-    @Test
-    public void testVoid() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        Object o = getContext().getService(cs_ref);
-        CheckService cs = (CheckService) o;
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1 (" + ((Integer) props.get("voidB")).intValue() + ")", ((Integer) props.get("voidB")).intValue(), 1);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID); // The instance was revalidated.
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance2.getInstanceName());
-        assertNotNull("Check CheckService availability - 2", cs_ref);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance2.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-    }
-
-    @Test
-    public void testObject() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 1);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance3.getInstanceName());
-        assertNotNull("Check CheckService availability - 2", cs_ref);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance3.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-    }
-
-    @Test
-    public void testRef() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 1);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 0);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance4.getInstanceName());
-        assertNotNull("Check CheckService availability - 2", cs_ref);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-    }
-
-    @Test
-    public void testBoth() {
-        ServiceReference arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check architecture availability", arch_ref);
-        InstanceDescription id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 1", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity", id.getState() == ComponentInstance.VALID);
-
-        ServiceReference cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability", cs_ref);
-        CheckService cs = (CheckService) getContext().getService(cs_ref);
-        Properties props = cs.getProps();
-        //Check properties
-        assertTrue("check CheckService invocation -1", ((Boolean) props.get("result")).booleanValue());
-        assertEquals("check void bind invocation -1", ((Integer) props.get("voidB")).intValue(), 0);
-        assertEquals("check void unbind callback invocation -1", ((Integer) props.get("voidU")).intValue(), 0);
-        assertEquals("check object bind callback invocation -1", ((Integer) props.get("objectB")).intValue(), 0);
-        assertEquals("check object unbind callback invocation -1", ((Integer) props.get("objectU")).intValue(), 0);
-        assertEquals("check ref bind callback invocation -1", ((Integer) props.get("refB")).intValue(), 0);
-        assertEquals("check ref unbind callback invocation -1", ((Integer) props.get("refU")).intValue(), 0);
-        assertEquals("check both bind callback invocation -1", ((Integer) props.get("bothB")).intValue(), 1);
-        assertEquals("check both unbind callback invocation -1", ((Integer) props.get("bothU")).intValue(), 0);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        fooProvider.start();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance validity - 2", id.getState() == ComponentInstance.VALID);
-
-        cs_ref = ipojoHelper.getServiceReferenceByName(CheckService.class.getName(), instance5.getInstanceName());
-        assertNotNull("Check CheckService availability - 2", cs_ref);
-
-        fooProvider.stop();
-
-        arch_ref = ipojoHelper.getServiceReferenceByName(Architecture.class.getName(), instance4.getInstanceName());
-        id = ((Architecture) getContext().getService(arch_ref)).getInstanceDescription();
-        assertTrue("Check instance invalidity - 2", id.getState() == ComponentInstance.INVALID);
-
-        id = null;
-        cs = null;
-        getContext().ungetService(arch_ref);
-    }
-
-}
