Replaced if with assertion for tests