replacing fromJust with an exception handling.
fixing a test.