Cleaned code and unit tests