@Test
public void addPaymentListener_StopListener_NoEvents() throws Exception {

    enqueueTransactionsResponses();
    final CountDownLatch latch = new CountDownLatch(1);
    final int[] eventsCount = {0};
    ListenerRegistration listenerRegistration = blockchainEvents
            .addPaymentListener(new EventListener<PaymentInfo>() {
                @Override
                public void onEvent(PaymentInfo data) {
                    eventsCount[0]++;
                    if (eventsCount[0] == 2) {
                        latch.countDown();
                    }
                }
            });
    assertTrue(latch.await(1, TimeUnit.SECONDS));
    listenerRegistration.remove();
    enqueueTransactionsResponses();
    enqueueTransactionsResponses();
    Thread.sleep(500);
    assertThat(eventsCount[0], equalTo(2));
}