CON-1445 add unit tests and move reused code to seperate methods