Refactoring trying to fix some logic issues

This is a refactoring to fix some strange/bad logic things (among which issue #71) in the current cookbook. This refactored version makes using additional features more robuust and clear.

Tested the new code using test-kitchen and some manual tests using the transport feature as target for the tests. Of course more testing is always welcome :wink: