TESTS: added unit tests to cover issue #505.