refactor ktest (contd.)