cleanup code
fix tests