Added logging, testing on exception handling

Exception handling