added tests and changed to instance methods