Update database mtimes in modify and write commands

First commit implements tests that are derived from the [specification in the wiki](https://github.com/sampsyo/beets/wiki/Architecture#modification-times-mtime).

Second commit tries to pass the tests by introducing a `try_sync()` method as discussed in #937.