Fix for state, node and task-nodes plus new tests for the cases added.
https://issues.jboss.org/browse/JBPM-3683