clean code and add automatic test