Add tests to check right error message is logged