Fixed major bugs in test