Fixes for record type typecode caching, and additional tests

The typecode caching for structured arrays that was added in a previous PR #869 does not actually work correctly, because it considers all structured types equal. This is because it only looks at the `type_num` of the type, which is always `NPY_VOID`.

This PR changes the caching so that it considers the fields of each record when comparing types, and adds caching for scalar types as well.

Additional tests are added that exercise the dispatcher's logic for typecode caching further. These tests also test the functionality of accessing structured array element fields by attribute, which is supported by Numba but not Numpy as outlined in #878.

See individual commit messages for further details.