Added tests, made config & logging more robust