Added protection for NaN values passed through setOptions.

Added tests.