Added function test, a lot of old code was removed and cleaned up in many files and the tests were also cleaned up.