Add comments and fix tests