added tests and removed an unused global variable