Refactor setting up context.

* Factor setting up log file and DB.
* Fix #1011.
* Groom imports.
Group dev mode inititializing code.
Expand tests of argument parser.

* Test for correct parsing of swtiches, both in long and short form.
* Disable failing test of --log-level for now.
Remove unused uptime timer.

* Remove unused import.
Treat DB and log paths as single entities.

* No reason to store folder and file separately.
* Use os.path.join to be as OS-agnostic as possible.
* --log is no more; use --log-path.
Enforce --log-level to accept an int argument.
Saner Market shutdown.

* Automated mutex acquisition and release.
* Renamed variables to document signal handling API.
Hide arg_to_key inside create_argument_parser.
Move and test ensure_directory.
Stricten tests of DB creation.

* Assert that after executing setup_db, we can connect to DB.
Move launcher tests to proper filename.