Feature/refactoring terms controller

Make Terms controller more dry.
Move logic into model.
Added tests.