finished optimize command impl
- partaial (non working) tests for optimize command