Fix for issue #34 and a NPE issue in if/elseif conditions

Pretty simple fix. Included @gitblit's unit test.

EDIT: Oops, failed at submitting a second PR... got merged into this one. Though the other one I wanted to fix is also related to if/elseif. Sorry about that!