Fix bug found by improved tests.
Fix bug found by improved tests.

pvtodorov/indra,pvtodorov/indra,sorgerlab/belpy,johnbachman/belpy,johnbachman/indra,sorgerlab/indra,johnbachman/belpy,johnbachman/indra,sorgerlab/belpy,bgyori/indra,bgyori/indra,sorgerlab/belpy,johnbachman/belpy,bgyori/indra,johnbachman/indra,pvtodorov/indra,sorgerlab/indra,sorgerlab/indra,pvtodorov/indra