Not quite sure why you first claim the device and then unclaim it again.
The behaviour is not surprising when you know how the registration process works.
Functions, variables and subscriptions are only registered with the cloud a short time after the connection to the cloud got established.
So in your case the functions were already registered with the cloud (but not any user account) before the device got claimed but claiming the device does not mean that the cloud connection would be ended and reestablished - it just persists.
Hence no re-registration will happen.
However, you may not need to completely restart the device but only reconnect to the cloud - with one caveat: In order to reduce data traffic a re-registration may be omitted when the the set of registered “items” doesn’t change too much over the course of a short connection loss.
What the “proper” way is depends on multiple factors.
How do you program?
Why do you program/claim that way?
Who owns the device before and after programming?