cleanup, improve out of order test
add docstrings;