Add tests and fix logic around affiliations retrieval

mixed styles? (2 and 4 tabs for identation)