refactor out core

to enable testing