incorrect usage of MAX_OPERATION_AGE
Better test cases and fixed a memory leak