bug fixes, more accurate tests