Create a method to handle the set_* method logic

This allows us to deduplicate most of the logic in those methods and by
abstracting it into a single method.

Change-Id: I56b6e1759aa4f6a3d8ceba85ca848935346ca6c0