Merge commit 'ee7538e03a76dbacb5599ed19810ae9b99605f13'

* commit 'ee7538e03a76dbacb5599ed19810ae9b99605f13':
  Added tests and slightly updated code for convenience
Remove changes unrelated to new tests and reformat for code style