Improve code thanks to comments, and add new test