Don't set bad values for options.
Fix setBooleanOrInherit.
Renamed bad to invalid.
Update after review.
Reduced code duplication.
Clean tests.
[#1541] Don't set bad values for options.
Merge master.