Fix bugs in test