Add unittest for config.py and database.py

- Also remove unused code and test code