Added tests and minor improvement for #43