First tests for am_scheduler and some refactoring