Refactored action execution mechanism.
Added test cases.