Move task test code to main. Fixed scheduling issues.