Throw an error if config is not correct, plus test and minor cleanup