cs fixes from scrutinizer and fix tests