remove debugging code; improve testing