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
```Hash#sort``` returns an array (the only way to sort a hash) and Array does not implement  ```#each_pair``` as far as I know.

```ruby
{"one" => [2, 3], "test" => [1, 2]}.sort  #=> [["one", [2, 3]], ["test", [1, 2]]]    
```