Updated exception handling with appropriate Exception types.
Cleanup trailing whitespaces in unit test class.
Added specific exception classes instead of generic exception.