Exceptions and tests.

Signed-off-by: Adrian Espinosa <aespinosamoreno@gmail.com>