Moved form logic into its own file, changed doc comments to match, and fixed failing test case.