Tests and improvement for #153

Added missing test cases for #153.