Refactor, adding test and Red-Hat family support