Refactor code in BundleHelper

This PR refactor duplicated code about extracting value from bundle.