Adding exceptions and tests