thread sleep function added

Mainly needed for unit testing