Split tests into multiple files
Minor code cleanup and comments