Fixes and added tests