Causal order fix

Change to use Map instead of Vector. Improved the test.