Minor refactoring + additional tests