@Test(expected = TestException.class)
public void testToIteratorWithException() {

    Observable<String> obs = Observable.create(new OnSubscribe<String>() {
        @Override
        public void call(Subscriber<? super String> observer) {
            observer.onNext("one");
            observer.onError(new TestException());
        }
    });
    Iterator<String> it = toIterator(obs);
    assertEquals(true, it.hasNext());
    assertEquals("one", it.next());
    assertEquals(true, it.hasNext());
    it.next();
}