Fix bug in flow dumping, add unit test that should have caught this in the first place