Fixes bug 1167780
Changed return values for some ensure_* functions to make them more consistent.
Now all ensure_* functions return None on failure and return the entity that was
created within the function when successful. Made changes to the unit tests to
reflect the changed return values.
Change-Id: Ib015ee7cee50bae5d91a4e109e7381519c1e14f7