Reorganize code around to improve coverage