Added custom exceptions and updated tests