moved test thread code into utilty BgThread class