Finish core::optional<T> internals, and add several tests.