Removing debug print
Fix #712 : "Fixed bug where variable filename was referenced before assignment when..."

Didn't use your code because it was ""too complex"" and the same was achieved without the extra variable.
Also added a unittest to make sure that this error won't happen again.

Thanks @johns3ej !