Changed throwing in handler. Added tests.