refactor for unittesting (cont.)