Refactor readsettings and add test