fixed bugs with message exchange for canceling messages

refactored AComplexDataType to reuse code

unit test