fixing flow + adding some tests