Error management improvement

Add tests to check several error cases to check if error code is well returned