Add non-generic GetDefinedAttributesFor method.

- Code refactoring.
- Add some unit tests.