Refactorings for nikola.utils.get_meta

Moved most of the logic into seperate functions.
Added a small testcase.