Finishing tests implementation with some bug fixes