If-then-else does not work properly

This PR is not a fix for the bug but it is a unit test which demonstrates the issue.  I thought that might be more useful than just a bug report. :)