fix crash with bogus config

Crash fix with bogus config. Testsuite added.