implemented FLAT_DIR functions and tests