added tests and fixed length not being updated