BUG TST: Closes #5313 PyArray_AsCArray caused segfault and adds testcase

This pull-request combines a cherry pick of a4163c4 (BUG: Closes #5313 PyArray_AsCArray caused segfault) and adds new test cases for PyArray_AsCArray.
Thus pull-request #5330 is now superfluous.