updated test and fixed code