replacing fromJust with an exception handling.
fixing a test.
test case for #118.