adding excpetions and tests