Fixed bugs in test, still one null pointer occasionally