Moved form fields and widgets code into common and added tests