added document key stuff and test for it