Fixed tests and treated all cases in manage_addDocument