remove debug code, improve testing