Changed so timestamp is added if not in the document, also added test