General cleanup and logging to file.

Logs to hwtest_log.txt, and it logs more specific things to the file than it would display to the screen, such as SoftAssert failures.

Cleaned up some stylistic issues that remained, and added a "common" folder for general useful functions. 
Could you try fwrite instead of fprintf here, just to see if it fixes the problem?