Added exception handling. Added test files