Added one unit test, cleaned up code a bit