Write PolysquareCommon and add unit tests.