updating test and inv so that the result is normalized.