Adding a callback to addDocument and also adding asserts to test.