Fixing issue #1104 and updating tests.

Don't you think this one is more readable and more elegant?
Anyway, you are the man in charge. I'll do whatever you say :)