John Legend was ‘tested’ by baby loss