reorganized & added tests