Two bugfixes + some tests

This patch:

a) Resolves the problem with multiple identical from __future__ statements added to the same file. In fact, I started diagnosing it after I saw

    from __future__ import print_function
    from __future__ import print_function
    from __future__ import print_function
    from __future__ import print_function
    (... and 13 more ...)

in one of my files

2) I added some unit-tests which verify both this problem and the problem I faced while trying to solve it
 ( https://gist.github.com/Mekk/1120216d29576cfae772 )
 I was running those tests with nosetests

If you don't like the way I fixed it, please at least take a look at tests.



2) After I fixed this problem (by removing strangely looking if condition), crash appeared while processing lines like {{{from a.b.c import d}}}. So I fixed it too.