debug and added tests