[ADD] some bug fixes
[ADD] adding tests