Hardening config loading and implementing proper unit tests.

Change-Id: I36c24abcc30c5eaa5244409ca9447990389791db