The Dataform class and Dataform managers classes (e.g. field manager, view manager etc.) can store active instances during script runtime. In current implementation the instances are stored in a static variable inside a class::instance() method. Conseqently, stored instances cannot be cleaned up from the outside. While this may not have any particular effect in normal operation of the Dataform, it may pose a problem during testing where tests may be run in a group and the static array of instances might not be initialized at the beginning of each test.
The proposed solution is to extract the instances management to a designated class 'instance_store' which will provide the api for registering, unregistering and retrieving an instance.
Since all instances belong to a specific dataform, the list can be associative with dataform ids as keys. Manager instances reside in inner lists for each dataform id. This way, on deleting a dataform all stored instances can be cleaned up by unsetting the list entry of the target dataform.