West Ham survive League Cup scare, Cardiff knocked out