fixed envelope issues
message handling redesigned
prepared junit tests
updated build script