Fix bugs in options module. Add more tests.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>