added tests

Added tests to run and also redid the code so that it would run
correctly.