Use `mock` library for changing global variables

We have changed global variables in Nailgun's tests, so they fall time to
time due to execution order. Since now we gonna use mock library to
perform such changes for tests.

Closes-Bug: #1393478
Change-Id: I3eea9aaa978db62d3eed094eb90f0466e0799569
Merge "Use `mock` library for changing global variables"