Finished adding tests. Added some exception handling.
Added test for main. Some cosmetic changes to keep same style in all files.