Fixed a bug where when mirror_local_mode lcd was not obeyed. Added tests.
Changed list of context managers in with statements into nested with
  statements so that tests pass on 2.6.
Refactored test code a bit
Changelog, closes #1146