merged changes, added tests