2014.7 file.replace integration test coverage

Based on the things reported in #18612, attempted to fix in #18615 and an additional case reported in #18841 I started to write some integration tests for `modules.file.replace()`.
All new tests work fine after applying the changes to `modules/file.py` also provided by this PR.

Besides the tests which are provided with this PR, some more things should be tested regarding `replace()` such as:
  * are the `flags` honored in all cases?
  * can matching groups be used in `repl` in different scenarios?
  * is `count` respected in different scenarios?
  * handling of `bufsize`/`bufsize='file'`? Do multiline operations work properly?

Due to time limits someone else will have to take care of those.