Improved SSH keygen and added comprehensive unit tests