Create auxiliary setup functions.
Refactor setting up context.

* Factor setting up log file and DB.
* Fix #1011.
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.

* Removed unused variables.
* Automated mutex acquisition and release.