warnings fixes

* fixing the warning for the unclosed files.
* using `with` and `print()` for the `__future__` in the tests.