I have now corrected this in commit 46ad445.

This actually made me review the code one more time. Thanks to this, I also found that in some tests (in this Pull Request) a few phases where not properly separated, so I aslo added b5db336.