Added unit tests for all field types (except T) and fixed a couple of bugs.