Split script, core, and tests into separate files