bug fixes, and better testing env