Fixed bug in test & occasionally occurring bug