added tests and incorporated feedback