Finish DynamicDocument implementation, move builtins, add tests.