[#1535] Fix resolving chained deferreds.

Problem description
===================

In case a callback from a chained deferred returns another deferred, _runDeferred does not wait for it to finish.


Why we got into this (5 whys)
=============================

* There was no tests for this use case.


Changes description
===================

Run all callbacks attached to a deferred in a loop.


How to try and test the changes
===============================

reviewers @alibotean 

Use this version in a separate project with problems. version 0.16.0 was released.

Check that code and test looks good.