improved promises flow
coding style
improved test suite for promises flow