update the code and add the test