Clear code and add tests