corrected tests and fixed code