Refactor forms and strengthen test suite