Move SharedDomain to Utils, add some tests.