more tests and some cleanup for variable and function lookup