fixed up tests and code cleanup