Fixed some warnings and unittest