Adding tests and fix for test fails & code cleanup

new line at the end - will fix it in next commit.