move settle functions to their own modules, add tests