fixed racing condition in tests, added new methods to create context