Fix bugs in test code #6