Refactor read configuration code of thm.py

* Move "read configuration" code to function
* Ignore lines starting in # in configuration file
* Add more queries to configuration file