update code to improve the test and fix identation on code