Refactor lookup functions and add basic tests for them.

All the lookup functions are refactored to use the new private lookup*
function. This allows the return type specific lookup functions to
directly specify the QName object for the type they return. The
general lookup function still needs to translate the keyword return
type to the necessary QName object.