Refactor serial_task

Added handling for lambdas in role definitions and rewrote the slice-building logic to use ruby idioms.

There was also an issue with getting roles from the wrong namespace (self.roles vs top.roles) in allow_optional_tasks and serial_task (line 94). Fixing this would resolve issue #279