Improved code style of field and wrote some tests