splitting core functions and test stuff