re-organize code; unit test code added; trying to fix serial communication problem