Implemented some unit tests. Tweaked GUI and refactored code.

you might not need to use threads. a timer should be sufficient.