Unit tests for HasTraits class

This PR provides further unit tests for the `HasTraits` class.