Add unit test, improve Scheduler