added missing #includes to test code
add missing includes; move some local decls to headers