Refactor hexToRgb method and tests