Ported and refactored patch from Code-11-SP2

Tests are ported into minitest.

See https://github.com/yast/yast-yast2/pull/109