fix bugs found in test