added test and implementation of method getCategoriesFromDocument