Added integration test and fixed a bug with zero length data