Test exception and logging