Test code cleanup and documentation