xorsum function and tests