added test for input fields and some refactoring