Adds tests for schedule, refactors