Add envelope() and its tests.