Code cleanup and some fixes

Some cleanup and tests needed in order to be able to work on bnc#907907 with confidence.

Sorry for not separating in commits the zombie killing from the spliting into smaller methods, but the latter is very simple (just moving the code a little bit).

https://bugzilla.suse.com/show_bug.cgi?id=907907
As stated in the comment, the problem with ```each_pair``` is that it does not grant a consistent order on every execution, which is needed by the old testsuite.