Refactor.

git-svn-id: http://farmanager.com/svn/trunk@9341 72235d2c-c60c-0410-a47a-a0032694dc5d
More tests

git-svn-id: http://farmanager.com/svn/trunk@9342 72235d2c-c60c-0410-a47a-a0032694dc5d