  @Test
  public void testUnregistering() {

    Object instance = mock( Object.class );
    referenceToInstanceMap.put( serviceReference, instance );
    DelayedInstanceNotifier delayedInstanceNotifier = mock( DelayedInstanceNotifier.class );
    when( delayedInstanceNotifierFactory.create( instance, LifecycleEvent.STOP ) )
      .thenReturn( delayedInstanceNotifier );
    bundleContextServiceListener.serviceChanged( new ServiceEvent( ServiceEvent.UNREGISTERING, serviceReference ) );
    verify( delayedInstanceNotifier ).run();
  }